# R Code for "Emphasizing Urgency of Climate Change No Silver Bullet to Increase Policy Support" ------------------------
# Authors: Lukas P. Fesenfeld, Adrian Rinscheid---------------------

#This script runs the statistical analyses----

# Set Working directory ---------------------------------------------------

# Set Package Directory ---------------------------------------------------

library(RCurl)
library(ggplot2)
library (mediation)
library("data.table")
library("aod")
library("car")
library(vctrs)
library(scales)
library("FSA")
library(sparsereg)
library(estimatr)
library(xlsx)


# import the function from repository
url_robust <- "https://raw.githubusercontent.com/IsidoreBeautrelet/economictheoryblog/master/robust_summary.R"
eval(parse(text = getURL(url_robust, ssl.verifypeer = FALSE)),
     envir=.GlobalEnv)

#Functions--------------
summarySE <- function(data=NULL, measurevar, groupvars=NULL, na.rm=FALSE,
                      conf.interval=.95, .drop=TRUE) {
  library(plyr)
  
  # New version of length which can handle NA's: if na.rm==T, don't count them
  length2 <- function (x, na.rm=FALSE) {
    if (na.rm) sum(!is.na(x))
    else       length(x)
  }
  
  # This does the summary. For each group's data frame, return a vector with
  # N, mean, and sd
  datac <- ddply(data, groupvars, .drop=.drop,
                 .fun = function(xx, col) {
                   c(N    = length2(xx[[col]], na.rm=na.rm),
                     mean = mean   (xx[[col]], na.rm=na.rm),
                     sd   = sd     (xx[[col]], na.rm=na.rm)
                   )
                 },
                 measurevar
  )
  
  # Rename the "mean" column    
  datac <- rename(datac, c("mean" = measurevar))
  
  datac$se <- datac$sd / sqrt(datac$N)  # Calculate standard error of the mean
  
  # Confidence interval multiplier for standard error
  # Calculate t-statistic for confidence interval: 
  # e.g., if conf.interval is .95, use .975 (above/below), and use df=N-1
  ciMult <- qt(conf.interval/2 + .5, datac$N-1)
  datac$ci <- datac$se * ciMult
  
  return(datac)
}

normFunc <- function(x){(x-mean(x, na.rm = T))/sd(x, na.rm = T)}

# Read Data ---------------------------------------------------------------

df_bind$treatmentGroup_f <- plyr::mapvalues(df_bind$treatmentGroup_f, c("Control", "Short", "Long", "Short-Context", "Long-Context"), c("Control","Short", "Long", "Short-\nContext", "Long-\nContext"))

df_bind$less_behave <- (df_bind$response_1_lesscar_n +df_bind$response_1_lessmeat_n)/2

df_bind$low_urgency <- ifelse(df_bind$problem_today=="No problem today but in future",1,0)
df_bind$high_urgency <- ifelse(df_bind$problem_today=="Problem today and in future",1,0)

df_bind$comp_n <- as.numeric(df_bind$comp)
df_bind$comp_n <- ifelse(df_bind$comp_n==1,0,1)

df_bind$comp <- as.factor(df_bind$comp)
df_bind_comp <- subset (df_bind, comp == levels (comp)[2])


df_bind_today <- subset (df_bind, problem_today == levels (problem_today)[2]|problem_today == levels (problem_today)[3])
table(df_bind_today$problem_today)
table(df_bind$problem_today,df_bind$country)
table(df_bind_Germany$problem_today)/4255
table(df_bind_USA$problem_today)/4877


pd <- position_dodge(0.1) # move them .05 to the left and right

table(df_bind_today$treatmentGroup_f,df_bind_today$country)

df_robust <-read.csv("./robustness_check.csv", sep = ",", dec = ",")

df_robust$treatmentGroup_f <- df_robust$hidfinalgroup
df_robust$treatmentGroup_f <- ifelse(df_robust$treatmentGroup_f ==4, "Short", "Long")
df_robust$treatmentGroup_f <- as.factor(df_robust$treatmentGroup_f)

df_robust$climate_costs <- as.numeric((df_robust$B7cr1+df_robust$B7cr3+df_robust$B7cr3)/3)
table(df_robust$climate_costs )

table (df_robust$comp2, df_robust$treatmentGroup_f)

df_robust$comp2_n <- as.numeric(df_robust$comp2)
df_robust$comp2_n <- ifelse(df_robust$comp2_n==1,0,1)


df_robust$problem_today <- ifelse(df_robust$climate_scep_a3_n >=4 & df_robust$climate_scep_a5_n <= 3, "No problem today but in future",
                           ifelse(df_robust$climate_scep_a3_n <= 3 & df_robust$climate_scep_a5_n <= 3, "Problem today and in future",
                                  ifelse(df_robust$climate_scep_a3_n >=4 & df_robust$climate_scep_a5_n >=4, "No problem today nor in future",
                                         ifelse(df_robust$climate_scep_a3_n <= 3 & df_robust$climate_scep_a5_n >=4, "Problem today but not in future", NA      
                                         ))))

df_robust$problem_today <- factor(df_robust$problem_today, levels = c("No problem today nor in future", "No problem today but in future","Problem today and in future", "Problem today but not in future"))

df_robust_today <- subset (df_robust, problem_today == levels (problem_today)[2]|problem_today == levels (problem_today)[3])

##Statistical Analysis---------

#Balance tests------

m.gender <- glm(gender=="Weiblich" ~ treatmentGroup_f, subset(df_bind, country == "Germany"), family=binomial())
summary(m.gender)

m.age <- lm(age_n ~ treatmentGroup_f, subset(df_bind, country == "Germany"))
summary(m.age)

m.educLow <- glm(educGRP=="Low (No professional education/college)" ~ treatmentGroup_f, subset(df_bind, country == "Germany"), family=binomial())
summary(m.educLow)

m.educMedium <- glm(educGRP=="Medium (Professional education)" ~ treatmentGroup_f, subset(df_bind, country == "Germany"), family=binomial())
summary(m.educMedium)

m.educHigh <- glm(educGRP=="High (University or technical degree)" ~ treatmentGroup_f, subset(df_bind, country == "Germany"), family=binomial())
summary(m.educHigh)

m.inc <- lm(inc_n ~ treatmentGroup_f, subset(df_bind, country == "Germany"))
summary(m.inc)

m.ideology <- lm(ideology_n ~ treatmentGroup_f, subset(df_bind, country == "Germany"))
summary(m.ideology)

m.sceptic <- lm(climate_scep ~ treatmentGroup_f, subset(df_bind, country == "Germany"))
summary(m.sceptic)

m.climate_scep_a3_n <- lm(climate_scep_a3_n ~ treatmentGroup_f, subset(df_bind, country == "Germany"))
summary(m.climate_scep_a3_n)

m.climate_scep_a5_n <- lm(climate_scep_a5_n ~ treatmentGroup_f, subset(df_bind, country == "Germany"))
summary(m.climate_scep_a5_n)

df_bind$comp_n <- as.numeric(df_bind$comp)

m.comp_n <- lm(comp_n ~ problem_today_bin , subset(df_bind, country == "Germany"))
summary(m.comp_n)

#Correlation Tests------

res_Germany <- cor.test(df_bind$climate_scep_a3_n [df_bind$country == "Germany"], df_bind$climate_scep_a5_n[df_bind$country == "Germany"], 
                method = "pearson")
res_Germany

res2_Germany <- cor.test(df_bind$low_urgency[df_bind$country == "Germany"], df_bind$high_urgency[df_bind$country == "Germany"], 
                method = "pearson")
res2_Germany

res_USA <- cor.test(df_bind$climate_scep_a3_n [df_bind$country == "USA"], df_bind$climate_scep_a5_n[df_bind$country == "USA"], 
                        method = "pearson")
res_USA

res2_USA <- cor.test(df_bind$low_urgency[df_bind$country == "USA"], df_bind$high_urgency[df_bind$country == "USA"], 
                         method = "pearson")
res2_USA

#Main Effects---------

#Manipulation Check----

#Compute OLS with robust standard errors for German sample
F2_main_manip_DE.ols <- lm_robust(comp_n ~ treatmentGroup_f, data= subset(df_bind_today, country == "Germany"))
summary(F2_main_manip_DE.ols)

# Compute the analysis of variance for German sample
F2_main_manip_DE.aov <- aov(comp_n ~ treatmentGroup_f, data= subset(df_bind_today, country == "Germany"))
# Summary of the analysis
summary(F2_main_manip_DE.aov)

TukeyHSD(F2_main_manip_DE.aov)

#Test anova assumptions
# 1. Homogeneity of variances
plot(F2_main_manip_DE.aov, 1)

# 2. Normality
plot(F2_main_manip_DE.aov, 2)

car::qqPlot(df_bind_today$comp_n [df_bind_today$country=="Germany"])

# Extract the residuals
F2_main_manip_DE.aov_residuals <- residuals(object = F2_main_manip_DE.aov )
# Run Shapiro-Wilk test
shapiro.test(x = F2_main_manip_DE.aov_residuals )

#non-parametric alternative to one-way ANOVA is Kruskal-Wallis rank sum test, which can be DEed when ANNOVA assumptions are not met
F2_main_manip_DE.krus <- kruskal.test(comp_n ~ treatmentGroup_f, data= subset(df_bind_today, country == "Germany"))
dunnTest(comp_n ~ treatmentGroup_f, data= subset(df_bind_today, country == "Germany"), two.sided=T)

#Compute OLS with robust standard errors for US sample
F2_main_manip_US.ols <- lm_robust(comp_n ~ treatmentGroup_f, data= subset(df_bind_today, country == "USA"))
summary(F2_main_manip_US.ols)

# Compute the analysis of variance for US sample
F2_main_manip_US.aov <- aov(comp_n ~ treatmentGroup_f, data= subset(df_bind_today, country == "USA"))
# Summary of the analysis
summary(F2_main_manip_US.aov)

TukeyHSD(F2_main_manip_US.aov)

#Test anova assumptions
# 1. Homogeneity of variances
plot(F2_main_manip_US.aov, 1)

# 2. Normality
plot(F2_main_manip_US.aov, 2)

# Extract the residuals
F2_main_manip_US.aov_residuals <- residuals(object = F2_main_manip_US.aov )
# Run Shapiro-Wilk test
shapiro.test(x = F2_main_manip_US.aov_residuals )

#non-parametric alternative to one-way ANOVA is KrUSkal-Wallis rank sum test, which can be USed when ANNOVA assumptions are not met
F2_main_manip_US.krus <- kruskal.test(comp_n ~ treatmentGroup_f, data= subset(df_bind_today, country == "USA"))

dunnTest(comp_n ~ treatmentGroup_f, data= subset(df_bind_today, country == "USA"), two.sided=T)

#As Robustness Check for sample including all respondents, also those that do not perceive climate change to be a problem today nor in future

#Compute OLS with robust standard errors for German sample, including all respondents
F2_main_all_manip_DE.ols <- lm_robust(comp_n ~ treatmentGroup_f, data= subset(df_bind, country == "Germany"))
summary(F2_main_all_manip_DE.ols)

#Compute OLS with robust standard errors for US sample, including all respondents
F2_main_all_manip_US.ols <- lm_robust(comp_n ~ treatmentGroup_f, data= subset(df_bind, country == "USA"))
summary(F2_main_all_manip_US.ols)

#Dread Outcome----

#Compute OLS with robust standard errors for German sample
F2_main_dread_DE.ols <- lm_robust(response_1_dread_n ~ treatmentGroup_f, data= subset(df_bind_today, country == "Germany"))
summary(F2_main_dread_DE.ols)

# Compute the analysis of variance for German sample
F2_main_dread_DE.aov <- aov(response_1_dread_n ~ treatmentGroup_f, data= subset(df_bind_today, country == "Germany"))
# Summary of the analysis
summary(F2_main_dread_DE.aov)

TukeyHSD(F2_main_dread_DE.aov)

#Test anova assumptions
# 1. Homogeneity of variances
plot(F2_main_dread_DE.aov, 1)

# 2. Normality
plot(F2_main_dread_DE.aov, 2)

car::qqPlot(df_bind_today$response_1_dread_n [df_bind_today$country=="Germany"])

# Extract the residuals
F2_main_dread_DE.aov_residuals <- residuals(object = F2_main_dread_DE.aov )
# Run Shapiro-Wilk test
shapiro.test(x = F2_main_dread_DE.aov_residuals )

#non-parametric alternative to one-way ANOVA is Kruskal-Wallis rank sum test, which can be DEed when ANNOVA assumptions are not met
F2_main_dread_DE.krus <- kruskal.test(response_1_dread_n ~ treatmentGroup_f, data= subset(df_bind_today, country == "Germany"))
table= dunnTest(response_1_dread_n ~ treatmentGroup_f, data= subset(df_bind_today, country == "Germany"), two.sided=T)
table = cbind.data.frame(table$res$Comparison,table$res$Z,table$res$P.adj)

write.xlsx(table, "C:/Users/lf20q095/Documents/ETH/Paper/Temporal Framing/First Resubmission/Data Analysis/dunntest_dread_DE.xlsx")

#Compute OLS with robust standard errors for US sample
F2_main_dread_US.ols <- lm_robust(response_1_dread_n ~ treatmentGroup_f, data= subset(df_bind_today, country == "USA"))
summary(F2_main_dread_US.ols)

# Compute the analysis of variance for US sample
F2_main_dread_US.aov <- aov(response_1_dread_n ~ treatmentGroup_f, data= subset(df_bind_today, country == "USA"))
# Summary of the analysis
summary(F2_main_dread_US.aov)

TukeyHSD(F2_main_dread_US.aov)

#Test anova assumptions
# 1. Homogeneity of variances
plot(F2_main_dread_US.aov, 1)

# 2. Normality
plot(F2_main_dread_US.aov, 2)

# Extract the residuals
F2_main_dread_US.aov_residuals <- residuals(object = F2_main_dread_US.aov )
# Run Shapiro-Wilk test
shapiro.test(x = F2_main_dread_US.aov_residuals )

#non-parametric alternative to one-way ANOVA is KrUSkal-Wallis rank sum test, which can be USed when ANNOVA assumptions are not met
F2_main_dread_US.krus <- kruskal.test(response_1_dread_n ~ treatmentGroup_f, data= subset(df_bind_today, country == "USA"))

table= dunnTest(response_1_dread_n ~ treatmentGroup_f, data= subset(df_bind_today, country == "USA"), two.sided=T)
table = cbind.data.frame(table$res$Comparison,table$res$Z,table$res$P.adj)

#As Robustness Check for sample including all respondents, also those that do not perceive climate change to be a problem today nor in future

#Compute OLS with robust standard errors for German sample, including all respondents
F2_main_all_dread_DE.ols <- lm_robust(response_1_dread_n ~ treatmentGroup_f, data= subset(df_bind, country == "Germany"))
summary(F2_main_all_dread_DE.ols)

#Compute OLS with robust standard errors for US sample, including all respondents
F2_main_all_dread_US.ols <- lm_robust(response_1_dread_n ~ treatmentGroup_f, data= subset(df_bind, country == "USA"))
summary(F2_main_all_dread_US.ols)

#General Mitigation Support Outcome------

#Compute OLS with robust standard errors for German sample
F2_main_mitigation_DE.ols <- lm_robust(response_1_mitigation_n ~ treatmentGroup_f, data= subset(df_bind_today, country == "Germany"))
summary(F2_main_mitigation_DE.ols)

# Compute the analysis of variance for German sample
F2_main_mitigation_DE.aov <- aov(response_1_mitigation_n ~ treatmentGroup_f, data= subset(df_bind_today, country == "Germany"))
# Summary of the analysis
summary(F2_main_mitigation_DE.aov)

TukeyHSD(F2_main_mitigation_DE.aov)

#Test anova assumptions
# 1. Homogeneity of variances
plot(F2_main_mitigation_DE.aov, 1)

# 2. Normality
plot(F2_main_mitigation_DE.aov, 2)

# Extract the residuals
F2_main_mitigation_DE.aov_residuals <- residuals(object = F2_main_mitigation_DE.aov )
# Run Shapiro-Wilk test
shapiro.test(x = F2_main_mitigation_DE.aov_residuals )

#non-parametric alternative to one-way ANOVA is Kruskal-Wallis rank sum test, which can be DEed when ANNOVA assumptions are not met
F2_main_mitigation_DE.krus <- kruskal.test(response_1_mitigation_n ~ treatmentGroup_f, data= subset(df_bind_today, country == "Germany"))

table= dunnTest(response_1_mitigation_n ~ treatmentGroup_f, data= subset(df_bind_today, country == "Germany"), two.sided=T)
table = cbind.data.frame(table$res$Comparison,table$res$Z,table$res$P.adj)

write.xlsx(table, "C:/Users/lf20q095/Documents/ETH/Paper/Temporal Framing/First Resubmission/Data Analysis/dunntest_mitigation_DE.xlsx")



#Compute OLS with robust standard errors for US sample

F2_main_mitigation_US.ols <- lm_robust(response_1_mitigation_n ~ treatmentGroup_f, data= subset(df_bind_today, country == "USA"))
summary(F2_main_mitigation_US.ols)

# Compute the analysis of variance for US sample
F2_main_mitigation_US.aov <- aov(response_1_mitigation_n ~ treatmentGroup_f, data= subset(df_bind_today, country == "USA"))
# Summary of the analysis
summary(F2_main_mitigation_US.aov)

TukeyHSD(F2_main_mitigation_US.aov)

#Test anova assumptions
# 1. Homogeneity of variances
plot(F2_main_mitigation_US.aov, 1)

# 2. Normality
plot(F2_main_mitigation_US.aov, 2)

# Extract the residuals
F2_main_mitigation_US.aov_residuals <- residuals(object = F2_main_mitigation_US.aov )
# Run Shapiro-Wilk test
shapiro.test(x = F2_main_mitigation_US.aov_residuals )

#non-parametric alternative to one-way ANOVA is Kruskal-Wallis rank sum test, which can be used when ANNOVA assumptions are not met
F2_main_mitigation_US.krus <- kruskal.test(response_1_mitigation_n ~ treatmentGroup_f, data= subset(df_bind_today, country == "USA"))

table=dunnTest(response_1_mitigation_n ~ treatmentGroup_f, data= subset(df_bind_today, country == "USA"), two.sided=T)
table = cbind.data.frame(table$res$Comparison,table$res$Z,table$res$P.adj)

#As Robustness Check for sample including all respondents, also those that do not perceive climate change to be a problem today nor in future

#Compute OLS with robust standard errors for German sample, including all respondents
F2_main_all_mitigation_DE.ols <- lm_robust(response_1_mitigation_n ~ treatmentGroup_f, data= subset(df_bind, country == "Germany"))
summary(F2_main_all_mitigation_DE.ols)

#Compute OLS with robust standard errors for US sample, including all respondents
F2_main_all_mitigation_US.ols <- lm_robust(response_1_mitigation_n ~ treatmentGroup_f, data= subset(df_bind, country == "USA"))
summary(F2_main_all_mitigation_US.ols)


#Demand-Side Mitigation Support Outcome------
#Compute OLS with robust standard errors for German sample
F2_main_less_behave_DE.ols <- lm_robust(less_behave ~ treatmentGroup_f, data= subset(df_bind_today, country == "Germany"))
summary(F2_main_less_behave_DE.ols)

table(df_bind$less_behave)

# Compute the analysis of variance for German sample
F2_main_less_behave_DE.aov <- aov(less_behave ~ treatmentGroup_f, data= subset(df_bind_today, country == "Germany"))
# Summary of the analysis
summary(F2_main_less_behave_DE.aov)

TukeyHSD(F2_main_less_behave_DE.aov)
library("multcomp")
summary(glht(F2_main_less_behave_DE.aov, linfct=mcp(treatmentGroup_f="Dunnett")))


#Test anova assumptions
# 1. Homogeneity of variances
plot(F2_main_less_behave_DE.aov, 1)

# 2. Normality
plot(F2_main_less_behave_DE.aov, 2)

# Extract the residuals
F2_main_less_behave_DE.aov_residuals <- residuals(object = F2_main_less_behave_DE.aov )
# Run Shapiro-Wilk test
shapiro.test(x = F2_main_less_behave_DE.aov_residuals )

#non-parametric alternative to one-way ANOVA is Kruskal-Wallis rank sum test, which can be used when ANNOVA assumptions are not met
F2_main_less_behave_DE.krus <- kruskal.test(less_behave ~ treatmentGroup_f, data= subset(df_bind_today, country == "Germany"))
table = dunnTest(less_behave ~ treatmentGroup_f, data= subset(df_bind_today, country == "Germany" ), two.sided=T)
table = cbind.data.frame(table$res$Comparison,table$res$Z,table$res$P.adj)


#Compute OLS with robust standard errors for US sample
F2_main_less_behave_US.ols <- lm_robust(less_behave ~ treatmentGroup_f, data= subset(df_bind_today, country == "USA"))
summary(F2_main_less_behave_US.ols)

# Compute the analysis of variance for US sample
F2_main_less_behave_US.aov <- aov(less_behave ~ treatmentGroup_f, data= subset(df_bind_today, country == "USA"))
# Summary of the analysis
summary(F2_main_less_behave_US.aov)

TukeyHSD(F2_main_less_behave_US.aov)

#Test anova assumptions
# 1. Homogeneity of variances
plot(F2_main_less_behave_US.aov, 1)

# 2. Normality
plot(F2_main_less_behave_US.aov, 2)

# Extract the residuals
F2_main_less_behave_US.aov_residuals <- residuals(object = F2_main_less_behave_US.aov )
# Run Shapiro-Wilk test
shapiro.test(x = F2_main_less_behave_US.aov_residuals )

#non-parametric alternative to one-way ANOVA is Kruskal-Wallis rank sum test, which can be used when ANNOVA assumptions are not met
F2_main_less_behave_US.krus <- kruskal.test(less_behave ~ treatmentGroup_f, data= subset(df_bind_today, country == "Germany"))
table=dunnTest(less_behave ~ treatmentGroup_f, data= subset(df_bind_today, country == "USA"), two.sided=T, list=T)
table = cbind.data.frame(table$res$Comparison,table$res$Z,table$res$P.adj)

#As Robustness Check for sample including all respondents, also those that do not perceive climate change to be a problem today nor in future

#Compute OLS with robust standard errors for German sample, including all respondents
F2_main_all_less_behave_DE.ols <- lm_robust(less_behave ~ treatmentGroup_f, data= subset(df_bind, country == "Germany"))
summary(F2_main_all_less_behave_DE.ols)

#Compute OLS with robust standard errors for US sample, including all respondents
F2_main_all_less_behave_US.ols <- lm_robust(less_behave ~ treatmentGroup_f, data= subset(df_bind, country == "USA"))
summary(F2_main_all_less_behave_US.ols)

#Heterogeneous Effects----------

#Dread Outcome----

#Compute OLS with robust standard errors for German sample
F2_marginal_dread_DE.ols <- lm_robust(response_1_dread_n ~ treatmentGroup_f*problem_today, data= subset(df_bind_today, country == "Germany"))
summary(F2_marginal_dread_DE.ols)

#Compute OLS with robust standard errors for US sample
F2_marginal_dread_US.ols <- lm_robust(response_1_dread_n ~ treatmentGroup_f*problem_today, data= subset(df_bind_today, country == "USA"))
summary(F2_marginal_dread_US.ols)

#As Robustness Check for sample including all respondents, also those that do not perceive climate change to be a problem today nor in future

#Compute OLS with robust standard errors for German sample
F2_marginal_all_dread_DE.ols <- lm_robust(response_1_dread_n ~ treatmentGroup_f*problem_today, data= subset(df_bind, country == "Germany"))
summary(F2_marginal_all_dread_DE.ols)

#Compute OLS with robust standard errors for US sample
F2_marginal_all_dread_US.ols <- lm_robust(response_1_dread_n ~ treatmentGroup_f*problem_today, data= subset(df_bind, country == "USA"))
summary(F2_marginal_all_dread_US.ols)

#General Mitigation Outcome----

#Compute OLS with robust standard errors for German sample
F2_marginal_mitigation_DE.ols <- lm_robust(response_1_mitigation_n ~ treatmentGroup_f*problem_today, data= subset(df_bind_today, country == "Germany"))
summary(F2_marginal_mitigation_DE.ols)

#Compute OLS with robust standard errors for US sample
F2_marginal_mitigation_US.ols <- lm_robust(response_1_mitigation_n ~ treatmentGroup_f*problem_today, data= subset(df_bind_today, country == "USA"))
summary(F2_marginal_mitigation_US.ols)

#As Robustness Check for sample including all respondents, also those that do not perceive climate change to be a problem today nor in future

#Compute OLS with robust standard errors for German sample
F2_marginal_all_mitigation_DE.ols <- lm_robust(response_1_mitigation_n ~ treatmentGroup_f*problem_today, data= subset(df_bind, country == "Germany"))
summary(F2_marginal_all_mitigation_DE.ols)

#Compute OLS with robust standard errors for US sample
F2_marginal_all_mitigation_US.ols <- lm_robust(response_1_mitigation_n ~ treatmentGroup_f*problem_today, data= subset(df_bind, country == "USA"))
summary(F2_marginal_all_mitigation_US.ols)


#Demand-Side Mitigation Support Outcome------

#Compute OLS with robust standard errors for German sample
F2_marginal_less_behave_DE.ols <- lm_robust(less_behave ~ treatmentGroup_f*problem_today, data= subset(df_bind_today, country == "Germany"))
summary(F2_marginal_less_behave_DE.ols)

#Compute OLS with robust standard errors for US sample
F2_marginal_less_behave_US.ols <- lm_robust(less_behave ~ treatmentGroup_f*problem_today, data= subset(df_bind_today, country == "USA"))
summary(F2_marginal_less_behave_US.ols)

#As Robustness Check for sample including all respondents, also those that do not perceive climate change to be a problem today nor in future

#Compute OLS with robust standard errors for German sample
F2_marginal_all_less_behave_DE.ols <- lm_robust(less_behave ~ treatmentGroup_f*problem_today, data= subset(df_bind, country == "Germany"))
summary(F2_marginal_all_less_behave_DE.ols)

#Compute OLS with robust standard errors for US sample
F2_marginal_all_less_behave_US.ols <- lm_robust(less_behave ~ treatmentGroup_f*problem_today, data= subset(df_bind, country == "USA"))
summary(F2_marginal_all_less_behave_US.ols)

#Robustness Survey----------

#Manipulation Check----

table(df_robust_today$comp2,df_robust_today$treatmentGroup_f)

#Compute OLS with robust standard errors for German sample
F2_main_manip_DE_robust.ols <- lm_robust(comp2_n ~ treatmentGroup_f, data= subset(df_robust_today))
summary(F2_main_manip_DE_robust.ols)

# Compute the analysis of variance for German sample
F2_main_manip_DE_robust.aov <- aov(comp2_n ~ treatmentGroup_f, data= subset(df_robust_today))
# Summary of the analysis
summary(F2_main_manip_DE_robust.aov)

TukeyHSD(F2_main_manip_DE_robust.aov)

#Test anova assumptions
# 1. Homogeneity of variances
plot(F2_main_manip_DE_robust.aov, 1)

# 2. Normality
plot(F2_main_manip_DE_robust.aov, 2)

car::qqPlot(df_robust_today$comp2_n)

# Extract the residuals
F2_main_manip_DE_robust.aov_residuals <- residuals(object = F2_main_manip_DE_robust.aov )
# Run Shapiro-Wilk test
shapiro.test(x = F2_main_manip_DE_robust.aov_residuals )

#non-parametric alternative to one-way ANOVA is Kruskal-Wallis rank sum test, which can be DEed when ANNOVA assumptions are not met
F2_main_manip_DE_robust.krus <- kruskal.test(comp2_n ~ treatmentGroup_f, data= subset(df_robust_today))
dunnTest(comp_n ~ treatmentGroup_f, data= subset(df_robust_today), two.sided=T)

#As Robustness Check for sample including all respondents, also those that do not perceive climate change to be a problem today nor in future

#Compute OLS with robust standard errors for German sample, including all respondents
F2_main_all_manip_DE.ols <- lm_robust(comp2_n ~ treatmentGroup_f, data= subset(df_robust))
summary(F2_main_all_manip_DE.ols)

#General Mitigation Outcome-----

#Compute OLS with robust standard errors for German sample
F2_main_mitigation_DE_robust.ols <- lm_robust(response_1_mitigation_n ~ treatmentGroup_f, data= subset(df_robust_today))
summary(F2_main_mitigation_DE_robust.ols)

# Compute the analysis of variance for German sample
F2_main_mitigation_DE_robust.aov <- aov(response_1_mitigation_n ~ treatmentGroup_f, data= subset(df_robust_today))
# Summary of the analysis
summary(F2_main_mitigation_DE_robust.aov)

TukeyHSD(F2_main_mitigation_DE_robust.aov)

#Test anova assumptions
# 1. Homogeneity of variances
plot(F2_main_mitigation_DE_robust.aov, 1)

# 2. Normality
plot(F2_main_mitigation_DE_robust.aov, 2)

# Extract the residuals
F2_main_mitigation_DE_robust.aov_residuals <- residuals(object = F2_main_mitigation_DE_robust.aov )
# Run Shapiro-Wilk test
shapiro.test(x = F2_main_mitigation_DE_robust.aov_residuals )

#non-parametric alternative to one-way ANOVA is Kruskal-Wallis rank sum test, which can be DEed when ANNOVA assumptions are not met
F2_main_mitigation_DE_robust.krus <- kruskal.test(response_1_mitigation_n ~ treatmentGroup_f, data= subset(df_robust_today))

#As Robustness Check for sample including all respondents, also those that do not perceive climate change to be a problem today nor in future

#Compute OLS with robust standard errors for German sample, including all respondents
F2_main_all_mitigation_DE.ols <- lm_robust(response_1_mitigation_n ~ treatmentGroup_f, data= subset(df_robust))
summary(F2_main_all_mitigation_DE.ols)

#Costly Mitigation Outcome-----

#Compute OLS with robust standard errors for German sample
F2_main_cost_mitigation_DE_robust.ols <- lm_robust(climate_costs ~ treatmentGroup_f, data= subset(df_robust_today))
summary(F2_main_cost_mitigation_DE_robust.ols)

# Compute the analysis of variance for German sample
F2_main_cost_mitigation_DE_robust.aov <- aov(climate_costs ~ treatmentGroup_f, data= subset(df_robust_today))
# Summary of the analysis
summary(F2_main_cost_mitigation_DE_robust.aov)

TukeyHSD(F2_main_cost_mitigation_DE_robust.aov)

#Test anova assumptions
# 1. Homogeneity of variances
plot(F2_main_cost_mitigation_DE_robust.aov, 1)

# 2. Normality
plot(F2_main_cost_mitigation_DE_robust.aov, 2)

# Extract the residuals
F2_main_cost_mitigation_DE_robust.aov_residuals <- residuals(object = F2_main_cost_mitigation_DE_robust.aov )
# Run Shapiro-Wilk test
shapiro.test(x = F2_main_cost_mitigation_DE_robust.aov_residuals )

#non-parametric alternative to one-way ANOVA is Kruskal-Wallis rank sum test, which can be DEed when ANNOVA assumptions are not met
F2_main_cost_mitigation_DE_robust.krus <- kruskal.test(climate_costs ~ treatmentGroup_f, data= subset(df_robust_today))

#As Robustness Check for sample including all respondents, also those that do not perceive climate change to be a problem today nor in future

#Compute OLS with robust standard errors for German sample, including all respondents
F2_main_all_cost_mitigation_DE.ols <- lm_robust(climate_costs ~ treatmentGroup_f, data= subset(df_robust))
summary(F2_main_all_cost_mitigation_DE.ols)


#Credibility Outcome-----

#Compute OLS with robust standard errors for German sample

F2_main_credible_DE_robust.ols <- lm_robust(credible ~ treatmentGroup_f, data= subset(df_robust_today))
summary(F2_main_credible_DE_robust.ols)

# Compute the analysis of variance for German sample
F2_main_credible_DE_robust.aov <- aov(credible ~ treatmentGroup_f, data= subset(df_robust_today))
# Summary of the analysis
summary(F2_main_credible_DE_robust.aov)

TukeyHSD(F2_main_credible_DE_robust.aov)

#Test anova assumptions
# 1. Homogeneity of variances
plot(F2_main_credible_DE_robust.aov, 1)

# 2. Normality
plot(F2_main_credible_DE_robust.aov, 2)

# Extract the residuals
F2_main_credible_DE_robust.aov_residuals <- residuals(object = F2_main_credible_DE_robust.aov )
# Run Shapiro-Wilk test
shapiro.test(x = F2_main_credible_DE_robust.aov_residuals )

#non-parametric alternative to one-way ANOVA is Kruskal-Wallis rank sum test, which can be DEed when ANNOVA assumptions are not met
F2_main_credible_DE_robust.krus <- kruskal.test(credible ~ treatmentGroup_f, data= subset(df_robust_today))

#As Robustness Check for sample including all respondents, also those that do not perceive climate change to be a problem today nor in future

#Compute OLS with robust standard errors for German sample, including all respondents
F2_main_all_credible_DE.ols <- lm_robust(credible ~ treatmentGroup_f, data= subset(df_robust))
summary(F2_main_all_credible_DE.ols)


#Prepare for LassoPlus Models---------

df_bind_USA <- subset(df_bind,country=="USA")
df_bind_Germany <- subset(df_bind,country=="Germany")

df_bind_today_USA <- subset(df_bind_today,country=="USA")
df_bind_today_Germany <- subset(df_bind_today,country=="Germany")

#df_bind_USA

df_bind_USA$response_1_direct_impact_other_z <- normFunc(df_bind_USA$response_1_direct_impact_other_n)
df_bind_USA$response_1_direct_impact_USA_z <- normFunc(df_bind_USA$response_1_direct_impact_usa_n)
df_bind_USA$response_1_direct_impact_self_z <- normFunc(df_bind_USA$response_1_direct_impact_self_n)
df_bind_USA$response_1_mitigation_z <-normFunc(df_bind_USA$response_1_mitigation_n)
df_bind_USA$response_1_dread_z<-normFunc(df_bind_USA$response_1_dread_n)
df_bind_USA$less_behave_z <-normFunc(df_bind_USA$less_behave)
df_bind_USA$gender_z <-normFunc(df_bind_USA$gender_n)
df_bind_USA$age_z <-normFunc(df_bind_USA$age_n)
df_bind_USA$education_z <-normFunc(df_bind_USA$education_n)
df_bind_USA$inc_z <-normFunc(df_bind_USA$inc_n)
df_bind_USA$children_z <-normFunc(df_bind_USA$children_n)
df_bind_USA$ideology_z <-normFunc(df_bind_USA$ideology_n)
df_bind_USA$tec_z <-normFunc(df_bind_USA$tec_n)
df_bind_USA$economy_z <-normFunc(df_bind_USA$economy_n)
df_bind_USA$climate_scep_a2_z <-normFunc(df_bind_USA$climate_scep_a2_n)
df_bind_USA$cfc_immediate_add_z <-normFunc(df_bind_USA$cfc_immediate_add)
df_bind_USA$cfc_future_add_z <-normFunc(df_bind_USA$cfc_future_add)
df_bind_USA$car_z <-normFunc(df_bind_USA$car_n)
df_bind_USA$priorknow_z <-normFunc(df_bind_USA$priorknow_n)
df_bind_USA$meatcon_z <-normFunc(df_bind_USA$meatcon_n)
df_bind_USA$problem_today_z <- normFunc(as.numeric(df_bind_USA$problem_today))
df_bind_USA$party_f <- as.factor(df_bind_USA$party)
df_bind_USA$Republican <- ifelse(df_bind_USA$party=="Republican", 1,0)
df_bind_USA$Republican_z <- normFunc(as.numeric(df_bind_USA$Republican))
df_bind_USA$Democrat <- ifelse(df_bind_USA$party=="Democrat", 1,0)
df_bind_USA$Democrat_z <- normFunc(as.numeric(df_bind_USA$Democrat))
df_bind_USA$Independent <- ifelse(df_bind_USA$party=="Independent", 1,0)
df_bind_USA$Independent_z <- normFunc(as.numeric(df_bind_USA$Independent))
df_bind_USA$Not_close <- ifelse(df_bind_USA$party=="Not close to any party", 1,0)
df_bind_USA$Not_close_z <- normFunc(as.numeric(df_bind_USA$Not_close))
df_bind_USA$Other <- ifelse(df_bind_USA$party=="Something else (please specify)", 1,0)
df_bind_USA$Other_z <- normFunc(as.numeric(df_bind_USA$Other))

#df_bind_today_USA

df_bind_today_USA$response_1_direct_impact_other_z <- normFunc(df_bind_today_USA$response_1_direct_impact_other_n)
df_bind_today_USA$response_1_direct_impact_USA_z <- normFunc(df_bind_today_USA$response_1_direct_impact_usa_n)
df_bind_today_USA$response_1_direct_impact_self_z <- normFunc(df_bind_today_USA$response_1_direct_impact_self_n)
df_bind_today_USA$response_1_mitigation_z <-normFunc(df_bind_today_USA$response_1_mitigation_n)
df_bind_today_USA$response_1_dread_z<-normFunc(df_bind_today_USA$response_1_dread_n)
df_bind_today_USA$less_behave_z <-normFunc(df_bind_today_USA$less_behave)
df_bind_today_USA$gender_z <-normFunc(df_bind_today_USA$gender_n)
df_bind_today_USA$age_z <-normFunc(df_bind_today_USA$age_n)
df_bind_today_USA$education_z <-normFunc(df_bind_today_USA$education_n)
df_bind_today_USA$inc_z <-normFunc(df_bind_today_USA$inc_n)
df_bind_today_USA$children_z <-normFunc(df_bind_today_USA$children_n)
df_bind_today_USA$ideology_z <-normFunc(df_bind_today_USA$ideology_n)
df_bind_today_USA$tec_z <-normFunc(df_bind_today_USA$tec_n)
df_bind_today_USA$economy_z <-normFunc(df_bind_today_USA$economy_n)
df_bind_today_USA$climate_scep_a2_z <-normFunc(df_bind_today_USA$climate_scep_a2_n)
df_bind_today_USA$cfc_immediate_add_z <-normFunc(df_bind_today_USA$cfc_immediate_add)
df_bind_today_USA$cfc_future_add_z <-normFunc(df_bind_today_USA$cfc_future_add)
df_bind_today_USA$car_z <-normFunc(df_bind_today_USA$car_n)
df_bind_today_USA$priorknow_z <-normFunc(df_bind_today_USA$priorknow_n)
df_bind_today_USA$meatcon_z <-normFunc(df_bind_today_USA$meatcon_n)
df_bind_today_USA$problem_today_z <- normFunc(as.numeric(df_bind_today_USA$problem_today))
df_bind_today_USA$party_f <- as.factor(df_bind_today_USA$party)
df_bind_today_USA$Republican <- ifelse(df_bind_today_USA$party=="Republican", 1,0)
df_bind_today_USA$Republican_z <- normFunc(as.numeric(df_bind_today_USA$Republican))
df_bind_today_USA$Democrat <- ifelse(df_bind_today_USA$party=="Democrat", 1,0)
df_bind_today_USA$Democrat_z <- normFunc(as.numeric(df_bind_today_USA$Democrat))
df_bind_today_USA$Independent <- ifelse(df_bind_today_USA$party=="Independent", 1,0)
df_bind_today_USA$Independent_z <- normFunc(as.numeric(df_bind_today_USA$Independent))
df_bind_today_USA$Not_close <- ifelse(df_bind_today_USA$party=="Not close to any party", 1,0)
df_bind_today_USA$Not_close_z <- normFunc(as.numeric(df_bind_today_USA$Not_close))
df_bind_today_USA$Other <- ifelse(df_bind_today_USA$party=="Something else (please specify)", 1,0)
df_bind_today_USA$Other_z <- normFunc(as.numeric(df_bind_today_USA$Other))

#df_bind_Germany

df_bind_Germany$response_1_direct_impact_other_z <- normFunc(df_bind_Germany$response_1_direct_impact_other_n)
df_bind_Germany$response_1_direct_impact_Germany_z <- normFunc(df_bind_Germany$response_1_direct_impact_Germany_n)
df_bind_Germany$response_1_direct_impact_self_z <- normFunc(df_bind_Germany$response_1_direct_impact_self_n)
df_bind_Germany$response_1_mitigation_z <-normFunc(df_bind_Germany$response_1_mitigation_n)
df_bind_Germany$response_1_dread_z<-normFunc(df_bind_Germany$response_1_dread_n)
df_bind_Germany$less_behave_z <-normFunc(df_bind_Germany$less_behave)
df_bind_Germany$gender_z <-normFunc(df_bind_Germany$gender_n)
df_bind_Germany$age_z <-normFunc(df_bind_Germany$age_n)
df_bind_Germany$education_z <-normFunc(df_bind_Germany$education_n)
df_bind_Germany$inc_z <-normFunc(df_bind_Germany$inc_n)
df_bind_Germany$children_z <-normFunc(df_bind_Germany$children_n)
df_bind_Germany$ideology_z <-normFunc(df_bind_Germany$ideology_n)
df_bind_Germany$tec_z <-normFunc(df_bind_Germany$tec_n)
df_bind_Germany$economy_z <-normFunc(df_bind_Germany$economy_n)
df_bind_Germany$climate_scep_a2_z <-normFunc(df_bind_Germany$climate_scep_a2_n)
df_bind_Germany$cfc_immediate_add_z <-normFunc(df_bind_Germany$cfc_immediate_add)
df_bind_Germany$cfc_future_add_z <-normFunc(df_bind_Germany$cfc_future_add)
df_bind_Germany$car_z <-normFunc(df_bind_Germany$car_n)
df_bind_Germany$priorknow_z <-normFunc(df_bind_Germany$priorknow_n)
df_bind_Germany$meatcon_z <-normFunc(df_bind_Germany$meatcon_n)
df_bind_Germany$problem_today_z <- normFunc(as.numeric(df_bind_Germany$problem_today))
df_bind_Germany$CDU_CSU <- ifelse(df_bind_Germany$party=="CDU"|df_bind_Germany$party=="CSU", 1,0)
df_bind_Germany$CDU_CSU_z <- normFunc(as.numeric(df_bind_Germany$CDU_CSU))
df_bind_Germany$AFD <- ifelse(df_bind_Germany$party=="AFD", 1,0)
df_bind_Germany$AFD_z <- normFunc(as.numeric(df_bind_Germany$AFD))
df_bind_Germany$Greens <- ifelse(df_bind_Germany$party=="Bündnis 90 / Die Grünen", 1,0)
df_bind_Germany$Greens_z <- normFunc(as.numeric(df_bind_Germany$Greens))
df_bind_Germany$Left <- ifelse(df_bind_Germany$party=="Die Linke", 1,0)
df_bind_Germany$Left_z <- normFunc(as.numeric(df_bind_Germany$Left))
df_bind_Germany$SPD <- ifelse(df_bind_Germany$party=="SPD", 1,0)
df_bind_Germany$SPD_z <- normFunc(as.numeric(df_bind_Germany$SPD))
df_bind_Germany$FDP <- ifelse(df_bind_Germany$party=="FDP", 1,0)
df_bind_Germany$FDP_z <- normFunc(as.numeric(df_bind_Germany$FDP))
df_bind_Germany$Not_close <- ifelse(df_bind_Germany$party=="", 1,0)
df_bind_Germany$Not_close_z <- normFunc(as.numeric(df_bind_Germany$Not_close))
df_bind_Germany$Other <- ifelse(df_bind_Germany$party=="Eine andere Partei, und zwar", 1,0)
df_bind_Germany$Other_z <- normFunc(as.numeric(df_bind_Germany$Other))

#df_bind_today_Germany

df_bind_today_Germany$response_1_direct_impact_other_z <- normFunc(df_bind_today_Germany$response_1_direct_impact_other_n)
df_bind_today_Germany$response_1_direct_impact_Germany_z <- normFunc(df_bind_today_Germany$response_1_direct_impact_Germany_n)
df_bind_today_Germany$response_1_direct_impact_self_z <- normFunc(df_bind_today_Germany$response_1_direct_impact_self_n)
df_bind_today_Germany$response_1_mitigation_z <-normFunc(df_bind_today_Germany$response_1_mitigation_n)
df_bind_today_Germany$response_1_dread_z<-normFunc(df_bind_today_Germany$response_1_dread_n)
df_bind_today_Germany$less_behave_z <-normFunc(df_bind_today_Germany$less_behave)
df_bind_today_Germany$gender_z <-normFunc(df_bind_today_Germany$gender_n)
df_bind_today_Germany$age_z <-normFunc(df_bind_today_Germany$age_n)
df_bind_today_Germany$education_z <-normFunc(df_bind_today_Germany$education_n)
df_bind_today_Germany$inc_z <-normFunc(df_bind_today_Germany$inc_n)
df_bind_today_Germany$children_z <-normFunc(df_bind_today_Germany$children_n)
df_bind_today_Germany$ideology_z <-normFunc(df_bind_today_Germany$ideology_n)
df_bind_today_Germany$tec_z <-normFunc(df_bind_today_Germany$tec_n)
df_bind_today_Germany$economy_z <-normFunc(df_bind_today_Germany$economy_n)
df_bind_today_Germany$climate_scep_a2_z <-normFunc(df_bind_today_Germany$climate_scep_a2_n)
df_bind_today_Germany$cfc_immediate_add_z <-normFunc(df_bind_today_Germany$cfc_immediate_add)
df_bind_today_Germany$cfc_future_add_z <-normFunc(df_bind_today_Germany$cfc_future_add)
df_bind_today_Germany$car_z <-normFunc(df_bind_today_Germany$car_n)
df_bind_today_Germany$priorknow_z <-normFunc(df_bind_today_Germany$priorknow_n)
df_bind_today_Germany$meatcon_z <-normFunc(df_bind_today_Germany$meatcon_n)
df_bind_today_Germany$problem_today_z <- normFunc(as.numeric(df_bind_today_Germany$problem_today))
df_bind_today_Germany$CDU_CSU <- ifelse(df_bind_today_Germany$party=="CDU"|df_bind_today_Germany$party=="CSU", 1,0)
df_bind_today_Germany$CDU_CSU_z <- normFunc(as.numeric(df_bind_today_Germany$CDU_CSU))
df_bind_today_Germany$AFD <- ifelse(df_bind_today_Germany$party=="AFD", 1,0)
df_bind_today_Germany$AFD_z <- normFunc(as.numeric(df_bind_today_Germany$AFD))
df_bind_today_Germany$Greens <- ifelse(df_bind_today_Germany$party=="Bündnis 90 / Die Grünen", 1,0)
df_bind_today_Germany$Greens_z <- normFunc(as.numeric(df_bind_today_Germany$Greens))
df_bind_today_Germany$Left <- ifelse(df_bind_today_Germany$party=="Die Linke", 1,0)
df_bind_today_Germany$Left_z <- normFunc(as.numeric(df_bind_today_Germany$Left))
df_bind_today_Germany$SPD <- ifelse(df_bind_today_Germany$party=="SPD", 1,0)
df_bind_today_Germany$SPD_z <- normFunc(as.numeric(df_bind_today_Germany$SPD))
df_bind_today_Germany$FDP <- ifelse(df_bind_today_Germany$party=="FDP", 1,0)
df_bind_today_Germany$FDP_z <- normFunc(as.numeric(df_bind_today_Germany$FDP))
df_bind_today_Germany$Not_close <- ifelse(df_bind_today_Germany$party=="", 1,0)
df_bind_today_Germany$Not_close_z <- normFunc(as.numeric(df_bind_today_Germany$Not_close))
df_bind_today_Germany$Other <- ifelse(df_bind_today_Germany$party=="Eine andere Partei, und zwar", 1,0)
df_bind_today_Germany$Other_z <- normFunc(as.numeric(df_bind_today_Germany$Other))

#New Datasets without NAs for LASSOplus
id <- 1:nrow(df_bind_USA)
df_bind_USA_na <- data.frame(id)


df_bind_USA_na$response_1_mitigation_n <- as.double(as.numeric(df_bind_USA$response_1_mitigation_n))
df_bind_USA_na$less_behave_n <- as.double(as.numeric(df_bind_USA$less_behave))
df_bind_USA_na$response_1_dread_n <- as.double(as.numeric(df_bind_USA$response_1_dread_n))

df_bind_USA_na$response_1_direct_impact_other_z <- as.double(as.numeric(df_bind_USA$response_1_direct_impact_other_z))
df_bind_USA_na$response_1_direct_impact_USA_z <- as.double(as.numeric(df_bind_USA$response_1_direct_impact_USA_z))
df_bind_USA_na$response_1_direct_impact_self_z <- as.double(as.numeric(df_bind_USA$response_1_direct_impact_self_z))

df_bind_USA_na$response_1_direct_impact_other_n <- as.double(as.numeric(df_bind_USA$response_1_direct_impact_other_n))
df_bind_USA_na$response_1_direct_impact_USA_n <- as.double(as.numeric(df_bind_USA$response_1_direct_impact_USA_n))
df_bind_USA_na$response_1_direct_impact_self_n <- as.double(as.numeric(df_bind_USA$response_1_direct_impact_self_n))
df_bind_USA_na$response_1_mitigation_z <- as.double(as.numeric(df_bind_USA$response_1_mitigation_z))
df_bind_USA_na$less_behave_z <- as.double(as.numeric(df_bind_USA$less_behave_z))
df_bind_USA_na$response_1_dread_z <- as.double(as.numeric(df_bind_USA$response_1_dread_z))

df_bind_USA_na$gender_z <-as.double(df_bind_USA$gender_z)
df_bind_USA_na$age_z <-df_bind_USA$age_z
df_bind_USA_na$education_z <- as.double(df_bind_USA$education_z)
df_bind_USA_na$inc_z <-as.double(df_bind_USA$inc_z)
df_bind_USA_na$children_z <-as.double(df_bind_USA$children_z)
df_bind_USA_na$ideology_z <-as.double(df_bind_USA$ideology_z)
df_bind_USA_na$tec_z <-as.double(df_bind_USA$tec_z)
df_bind_USA_na$economy_z <-as.double(df_bind_USA$economy_z)
df_bind_USA_na$climate_scep_a2_z <-as.double(df_bind_USA$climate_scep_a2_z)
df_bind_USA_na$cfc_immediate_add_z <-as.double(df_bind_USA$cfc_immediate_add_z)
df_bind_USA_na$cfc_future_add_z <-as.double(df_bind_USA$cfc_future_add_z)
df_bind_USA_na$priorknow_z <-as.double(df_bind_USA$priorknow_z)
df_bind_USA_na$car_z <-as.double(df_bind_USA$car_z)
df_bind_USA_na$meatcon_z <-as.double(df_bind_USA$meatcon_z)
df_bind_USA_na$problem_today_z <- as.double (df_bind_USA$problem_today_z)
df_bind_USA_na$Republican_z <- as.double (df_bind_USA$Republican_z)
df_bind_USA_na$Democrat_z <- as.double (df_bind_USA$Democrat_z)
df_bind_USA_na$Independent_z <- as.double (df_bind_USA$Independent_z)
df_bind_USA_na$Other_z <- as.double (df_bind_USA$Other_z)
df_bind_USA_na$Not_close_z <- as.double (df_bind_USA$Not_close_z)

df_bind_USA_na$treatmentGroup_f <- as.factor(df_bind_USA$treatmentGroup_f)
df_bind_USA_na<- na.omit(df_bind_USA_na) 

id <- 1:nrow(df_bind_today_USA)
df_bind_today_USA_na <- data.frame(id)

df_bind_today_USA_na$response_1_mitigation_n <- as.double(as.numeric(df_bind_today_USA$response_1_mitigation_n))
df_bind_today_USA_na$less_behave_n <- as.double(as.numeric(df_bind_today_USA$less_behave))
df_bind_today_USA_na$response_1_dread_n <- as.double(as.numeric(df_bind_today_USA$response_1_dread_n))

df_bind_today_USA_na$response_1_direct_impact_other_z <- as.double(as.numeric(df_bind_today_USA$response_1_direct_impact_other_z))
df_bind_today_USA_na$response_1_direct_impact_USA_z <- as.double(as.numeric(df_bind_today_USA$response_1_direct_impact_USA_z))
df_bind_today_USA_na$response_1_direct_impact_self_z <- as.double(as.numeric(df_bind_today_USA$response_1_direct_impact_self_z))

df_bind_today_USA_na$response_1_direct_impact_other_n <- as.double(as.numeric(df_bind_today_USA$response_1_direct_impact_other_n))
df_bind_today_USA_na$response_1_direct_impact_USA_n <- as.double(as.numeric(df_bind_today_USA$response_1_direct_impact_USA_n))
df_bind_today_USA_na$response_1_direct_impact_self_n <- as.double(as.numeric(df_bind_today_USA$response_1_direct_impact_self_n))
df_bind_today_USA_na$response_1_mitigation_z <- as.double(as.numeric(df_bind_today_USA$response_1_mitigation_z))
df_bind_today_USA_na$less_behave_z <- as.double(as.numeric(df_bind_today_USA$less_behave_z))
df_bind_today_USA_na$response_1_dread_z <- as.double(as.numeric(df_bind_today_USA$response_1_dread_z))

df_bind_today_USA_na$gender_z <-as.double(df_bind_today_USA$gender_z)
df_bind_today_USA_na$age_z <-df_bind_today_USA$age_z
df_bind_today_USA_na$education_z <- as.double(df_bind_today_USA$education_z)
df_bind_today_USA_na$inc_z <-as.double(df_bind_today_USA$inc_z)
df_bind_today_USA_na$children_z <-as.double(df_bind_today_USA$children_z)
df_bind_today_USA_na$ideology_z <-as.double(df_bind_today_USA$ideology_z)
df_bind_today_USA_na$tec_z <-as.double(df_bind_today_USA$tec_z)
df_bind_today_USA_na$economy_z <-as.double(df_bind_today_USA$economy_z)
df_bind_today_USA_na$climate_scep_a2_z <-as.double(df_bind_today_USA$climate_scep_a2_z)
df_bind_today_USA_na$cfc_immediate_add_z <-as.double(df_bind_today_USA$cfc_immediate_add_z)
df_bind_today_USA_na$cfc_future_add_z <-as.double(df_bind_today_USA$cfc_future_add_z)
df_bind_today_USA_na$priorknow_z <-as.double(df_bind_today_USA$priorknow_z)
df_bind_today_USA_na$car_z <-as.double(df_bind_today_USA$car_z)
df_bind_today_USA_na$meatcon_z <-as.double(df_bind_today_USA$meatcon_z)
df_bind_today_USA_na$problem_today_z <- as.double (df_bind_today_USA$problem_today_z)
df_bind_today_USA_na$Republican_z <- as.double (df_bind_today_USA$Republican_z)
df_bind_today_USA_na$Democrat_z <- as.double (df_bind_today_USA$Democrat_z)
df_bind_today_USA_na$Independent_z <- as.double (df_bind_today_USA$Independent_z)
df_bind_today_USA_na$Other_z <- as.double (df_bind_today_USA$Other_z)
df_bind_today_USA_na$Not_close_z <- as.double (df_bind_today_USA$Not_close_z)

df_bind_today_USA_na$treatmentGroup_f <- as.factor(df_bind_today_USA$treatmentGroup_f)
df_bind_today_USA_na<- na.omit(df_bind_today_USA_na) 


id <- 1:nrow(df_bind_Germany)
df_bind_Germany_na <- data.frame(id)

df_bind_Germany_na$response_1_mitigation_n <- as.double(as.numeric(df_bind_Germany$response_1_mitigation_n))
df_bind_Germany_na$less_behave_n <- as.double(as.numeric(df_bind_Germany$less_behave))
df_bind_Germany_na$response_1_dread_n <- as.double(as.numeric(df_bind_Germany$response_1_dread_n))

df_bind_Germany_na$response_1_direct_impact_other_z <- as.double(as.numeric(df_bind_Germany$response_1_direct_impact_other_z))
df_bind_Germany_na$response_1_direct_impact_Germany_z <- as.double(as.numeric(df_bind_Germany$response_1_direct_impact_Germany_z))
df_bind_Germany_na$response_1_direct_impact_self_z <- as.double(as.numeric(df_bind_Germany$response_1_direct_impact_self_z))

df_bind_Germany_na$response_1_direct_impact_other_n <- as.double(as.numeric(df_bind_Germany$response_1_direct_impact_other_n))
df_bind_Germany_na$response_1_direct_impact_Germany_n <- as.double(as.numeric(df_bind_Germany$response_1_direct_impact_Germany_n))
df_bind_Germany_na$response_1_direct_impact_self_n <- as.double(as.numeric(df_bind_Germany$response_1_direct_impact_self_n))
df_bind_Germany_na$response_1_mitigation_z <- as.double(as.numeric(df_bind_Germany$response_1_mitigation_z))
df_bind_Germany_na$less_behave_z <- as.double(as.numeric(df_bind_Germany$less_behave_z))
df_bind_Germany_na$response_1_dread_z <- as.double(as.numeric(df_bind_Germany$response_1_dread_z))

df_bind_Germany_na$gender_z <-as.double(df_bind_Germany$gender_z)
df_bind_Germany_na$age_z <-df_bind_Germany$age_z
df_bind_Germany_na$education_z <- as.double(df_bind_Germany$education_z)
df_bind_Germany_na$inc_z <-as.double(df_bind_Germany$inc_z)
df_bind_Germany_na$children_z <-as.double(df_bind_Germany$children_z)
df_bind_Germany_na$ideology_z <-as.double(df_bind_Germany$ideology_z)
df_bind_Germany_na$tec_z <-as.double(df_bind_Germany$tec_z)
df_bind_Germany_na$economy_z <-as.double(df_bind_Germany$economy_z)
df_bind_Germany_na$climate_scep_a2_z <-as.double(df_bind_Germany$climate_scep_a2_z)
df_bind_Germany_na$cfc_immediate_add_z <-as.double(df_bind_Germany$cfc_immediate_add_z)
df_bind_Germany_na$cfc_future_add_z <-as.double(df_bind_Germany$cfc_future_add_z)
df_bind_Germany_na$priorknow_z <-as.double(df_bind_Germany$priorknow_z)
df_bind_Germany_na$car_z <-as.double(df_bind_Germany$car_z)
df_bind_Germany_na$meatcon_z <-as.double(df_bind_Germany$meatcon_z)
df_bind_Germany_na$problem_today_z <- as.double (df_bind_Germany$problem_today_z)
df_bind_Germany_na$CDU_CSU_z <- as.double (df_bind_Germany$CDU_CSU_z)
df_bind_Germany_na$AFD_z <- as.double (df_bind_Germany$AFD_z)
df_bind_Germany_na$Greens_z <- as.double (df_bind_Germany$Greens_z)
df_bind_Germany_na$Left_z <- as.double (df_bind_Germany$Left_z)
df_bind_Germany_na$SPD_z <- as.double (df_bind_Germany$SPD_z)
df_bind_Germany_na$FDP_z <- as.double (df_bind_Germany$FDP_z)
df_bind_Germany_na$Not_close_z <- as.double (df_bind_Germany$Not_close_z)
df_bind_Germany_na$Other_z <- as.double (df_bind_Germany$Other_z)


df_bind_Germany_na$treatmentGroup_f <- as.factor(df_bind_Germany$treatmentGroup_f)
df_bind_Germany_na<- na.omit(df_bind_Germany_na) 

id <- 1:nrow(df_bind_today_Germany)
df_bind_today_Germany_na <- data.frame(id)

df_bind_today_Germany_na$response_1_direct_impact_other_z <- as.double(as.numeric(df_bind_today_Germany$response_1_direct_impact_other_z))
df_bind_today_Germany_na$response_1_direct_impact_Germany_z <- as.double(as.numeric(df_bind_today_Germany$response_1_direct_impact_Germany_z))
df_bind_today_Germany_na$response_1_direct_impact_self_z <- as.double(as.numeric(df_bind_today_Germany$response_1_direct_impact_self_z))

df_bind_today_Germany_na$response_1_direct_impact_other_n <- as.double(as.numeric(df_bind_today_Germany$response_1_direct_impact_other_n))
df_bind_today_Germany_na$response_1_direct_impact_Germany_n <- as.double(as.numeric(df_bind_today_Germany$response_1_direct_impact_Germany_n))
df_bind_today_Germany_na$response_1_direct_impact_self_n <- as.double(as.numeric(df_bind_today_Germany$response_1_direct_impact_self_n))
df_bind_today_Germany_na$response_1_mitigation_n <- as.double(as.numeric(df_bind_today_Germany$response_1_mitigation_n))
df_bind_today_Germany_na$less_behave_n <- as.double(as.numeric(df_bind_today_Germany$less_behave))
df_bind_today_Germany_na$response_1_dread_n <- as.double(as.numeric(df_bind_today_Germany$response_1_dread_n))

df_bind_today_Germany_na$response_1_mitigation_z <- as.double(as.numeric(df_bind_today_Germany$response_1_mitigation_z))
df_bind_today_Germany_na$less_behave_z <- as.double(as.numeric(df_bind_today_Germany$less_behave_z))
df_bind_today_Germany_na$response_1_dread_z <- as.double(as.numeric(df_bind_today_Germany$response_1_dread_z))

df_bind_today_Germany_na$gender_z <-as.double(df_bind_today_Germany$gender_z)
df_bind_today_Germany_na$age_z <-df_bind_today_Germany$age_z
df_bind_today_Germany_na$education_z <- as.double(df_bind_today_Germany$education_z)
df_bind_today_Germany_na$inc_z <-as.double(df_bind_today_Germany$inc_z)
df_bind_today_Germany_na$children_z <-as.double(df_bind_today_Germany$children_z)
df_bind_today_Germany_na$ideology_z <-as.double(df_bind_today_Germany$ideology_z)
df_bind_today_Germany_na$tec_z <-as.double(df_bind_today_Germany$tec_z)
df_bind_today_Germany_na$economy_z <-as.double(df_bind_today_Germany$economy_z)
df_bind_today_Germany_na$climate_scep_a2_z <-as.double(df_bind_today_Germany$climate_scep_a2_z)
df_bind_today_Germany_na$cfc_immediate_add_z <-as.double(df_bind_today_Germany$cfc_immediate_add_z)
df_bind_today_Germany_na$cfc_future_add_z <-as.double(df_bind_today_Germany$cfc_future_add_z)
df_bind_today_Germany_na$priorknow_z <-as.double(df_bind_today_Germany$priorknow_z)
df_bind_today_Germany_na$car_z <-as.double(df_bind_today_Germany$car_z)
df_bind_today_Germany_na$meatcon_z <-as.double(df_bind_today_Germany$meatcon_z)
df_bind_today_Germany_na$problem_today_z <- as.double (df_bind_today_Germany$problem_today_z)
df_bind_today_Germany_na$CDU_CSU_z <- as.double (df_bind_today_Germany$CDU_CSU_z)
df_bind_today_Germany_na$AFD_z <- as.double (df_bind_today_Germany$AFD_z)
df_bind_today_Germany_na$Greens_z <- as.double (df_bind_today_Germany$Greens_z)
df_bind_today_Germany_na$Left_z <- as.double (df_bind_today_Germany$Left_z)
df_bind_today_Germany_na$SPD_z <- as.double (df_bind_today_Germany$SPD_z)
df_bind_today_Germany_na$FDP_z <- as.double (df_bind_today_Germany$FDP_z)
df_bind_today_Germany_na$Not_close_z <- as.double (df_bind_today_Germany$Not_close_z)
df_bind_today_Germany_na$Other_z <- as.double (df_bind_today_Germany$Other_z)

df_bind_today_Germany_na$treatmentGroup_f <- as.factor(df_bind_today_Germany$treatmentGroup_f)
df_bind_today_Germany_na<- na.omit(df_bind_today_Germany_na) 


#Estimate LassoPlus Models for Outcomes (Please note that this will require some computational power and time to run all models)---------

#Dread
set.seed(1)

out_response_1_dread_n_USA <- sparsereg::sparsereg(y = df_bind_today_USA_na$response_1_dread_n, 
                                                        X = as.matrix(data.frame(Republican =df_bind_today_USA_na$Republican_z,Democrat =df_bind_today_USA_na$Democrat_z, Independent =df_bind_today_USA_na$Independent_z,Other =df_bind_today_USA_na$Other_z,Not_Close_To_Party =df_bind_today_USA_na$Not_close_z,Gender = df_bind_today_USA_na$gender_z ,Age = df_bind_today_USA_na$age_z , Education =df_bind_today_USA_na$education_z ,Income = df_bind_today_USA_na$inc_z ,Ideology =df_bind_today_USA_na$ideology_z, Number_Children = df_bind_today_USA_na$children_z,Lifestyle_Change = df_bind_today_USA_na$tec_z , State_Intervention = df_bind_today_USA_na$economy_z, Humans_Not_Cause= df_bind_today_USA_na$climate_scep_a2_z,CFC_Future= df_bind_today_USA_na$cfc_future_add_z,  Climate_Knowledge =df_bind_today_USA_na$priorknow_z ,Car_Use = df_bind_today_USA_na$car_z ,Meat_Consumption=df_bind_today_USA_na$meatcon_z , Perceived_Urgency=df_bind_today_USA_na$problem_today_z )),
                                                        treat = df_bind_today_USA_na$treatmentGroup_f,
                                                        scale.type = "TTX",
                                                        baseline.vec = c("Control"),
                                                        gibbs=1000, burnin=1000)

sparsereg::plot.sparsereg(out_response_1_dread_n_USA, plot.one =1, main1 = "US: Dread - Selected Main Effects", xlabel = "Posterior Median of Standardized Effects")
sparsereg::summary.sparsereg(out_response_1_dread_n_USA)

set.seed(1)

out_response_1_dread_n_Germany <- sparsereg::sparsereg(y = df_bind_today_Germany_na$response_1_dread_n, 
                                                            X = as.matrix(data.frame(AFD =df_bind_today_Germany_na$AFD_z,FDP =df_bind_today_Germany_na$FDP_z,Left =df_bind_today_Germany_na$Left_z, SPD =df_bind_today_Germany_na$SPD_z,Greens =df_bind_today_Germany_na$Greens_z,CDU_CSU =df_bind_today_Germany_na$CDU_CSU_z,Other =df_bind_today_Germany_na$Other_z,Not_Close_To_Party =df_bind_today_Germany_na$Not_close_z,Gender = df_bind_today_Germany_na$gender_z ,Age = df_bind_today_Germany_na$age_z , Education =df_bind_today_Germany_na$education_z ,Income = df_bind_today_Germany_na$inc_z ,Ideology =df_bind_today_Germany_na$ideology_z, Number_Children = df_bind_today_Germany_na$children_z,Lifestyle_Change = df_bind_today_Germany_na$tec_z ,State_Intervention = df_bind_today_Germany_na$economy_z , Humans_Not_Cause= df_bind_today_Germany_na$climate_scep_a2_z,CFC_Future= df_bind_today_Germany_na$cfc_future_add_z,  Climate_Knowledge =df_bind_today_Germany_na$priorknow_z ,Car_Use = df_bind_today_Germany_na$car_z ,Meat_Consumption=df_bind_today_Germany_na$meatcon_z , Perceived_Urgency=df_bind_today_Germany_na$problem_today_z )),
                                                            treat = df_bind_today_Germany_na$treatmentGroup_f,
                                                            scale.type = "TTX",
                                                            baseline.vec = c("Control"),
                                                            gibbs=1000, burnin=1000)


sparsereg::plot.sparsereg(out_response_1_dread_n_Germany, plot.one =1, main1 = "Germany: Dread - Selected Main Effects", xlabel = "Posterior Median of Standardized Effects")
sparsereg::summary.sparsereg(out_response_1_dread_n_Germany)

#As Robustness Check for sample including all respondents, also those that do not perceive climate change to be a problem today nor in future

set.seed(1)

table(df_bind_USA_na$response_1_dread_n)

out_response_1_dread_n_USA_all <- sparsereg::sparsereg(y = df_bind_USA_na$response_1_dread_n, 
                                                            X = as.matrix(data.frame(Republican =df_bind_USA_na$Republican_z,Democrat =df_bind_USA_na$Democrat_z, Independent =df_bind_USA_na$Independent_z,Other =df_bind_USA_na$Other_z,Not_Close_To_Party =df_bind_USA_na$Not_close_z,Gender = df_bind_USA_na$gender_z ,Age = df_bind_USA_na$age_z , Education =df_bind_USA_na$education_z ,Income = df_bind_USA_na$inc_z ,Ideology =df_bind_USA_na$ideology_z, Number_Children = df_bind_USA_na$children_z,Lifestyle_Change = df_bind_USA_na$tec_z ,State_Intervention = df_bind_USA_na$economy_z , Humans_Not_Cause= df_bind_USA_na$climate_scep_a2_z,CFC_Immediate = df_bind_USA_na$cfc_immediate_add_z,CFC_Future= df_bind_USA_na$cfc_future_add_z,  Climate_Knowledge =df_bind_USA_na$priorknow_z ,Car_Use = df_bind_USA_na$car_z ,Meat_Consumption=df_bind_USA_na$meatcon_z , Perceived_Urgency=df_bind_USA_na$problem_z )),
                                                            treat = df_bind_USA_na$treatmentGroup_f,
                                                            scale.type = "TTX",
                                                            baseline.vec = c("Control"),
                                                            gibbs=1000, burnin=1000)

sparsereg::plot.sparsereg(out_response_1_dread_n_USA_all, plot.one =1, main1 = "US: Dread - Selected Main Effects (Entire Sample)", xlabel = "Posterior Median of Standardized Effects")
sparsereg::summary.sparsereg(out_response_1_dread_n_USA_all)

set.seed(1)

out_response_1_dread_n_Germany_all <- sparsereg::sparsereg(y = df_bind_Germany_na$response_1_dread_n, 
                                                                X = as.matrix(data.frame(AFD =df_bind_Germany_na$AFD_z,FDP =df_bind_Germany_na$FDP_z,Left =df_bind_Germany_na$Left_z, SPD =df_bind_Germany_na$SPD_z,Greens =df_bind_Germany_na$Greens_z,CDU_CSU =df_bind_Germany_na$CDU_CSU_z,Other =df_bind_Germany_na$Other_z,Not_Close_To_Party =df_bind_Germany_na$Not_close_z,Gender = df_bind_Germany_na$gender_z ,Age = df_bind_Germany_na$age_z , Education =df_bind_Germany_na$education_z ,Income = df_bind_Germany_na$inc_z ,Ideology =df_bind_Germany_na$ideology_z, Number_Children = df_bind_Germany_na$children_z,Lifestyle_Change = df_bind_Germany_na$tec_z ,State_Intervention = df_bind_Germany_na$economy_z , Humans_Not_Cause= df_bind_Germany_na$climate_scep_a2_z,CFC_Immediate = df_bind_Germany_na$cfc_immediate_add_z,CFC_Future= df_bind_Germany_na$cfc_future_add_z,  Climate_Knowledge =df_bind_Germany_na$priorknow_z ,Car_Use = df_bind_Germany_na$car_z ,Meat_Consumption=df_bind_Germany_na$meatcon_z , Perceived_Urgency=df_bind_Germany_na$problem_z )),
                                                                treat = df_bind_Germany_na$treatmentGroup_f,
                                                                scale.type = "TTX",
                                                                baseline.vec = c("Control"),
                                                                gibbs=1000, burnin=1000)

sparsereg::plot.sparsereg(out_response_1_dread_n_Germany_all, plot.one =1, main1 = "Germany: Dread - Selected Main Effects (Entire Sample)", xlabel = "Posterior Median of Standardized Effects")
sparsereg::summary.sparsereg(out_response_1_dread_n_Germany_all)


#Direct Concern for Yourself
set.seed(1)

out_response_1_direct_impact_self_n_USA <- sparsereg::sparsereg(y = df_bind_today_USA_na$response_1_direct_impact_self_n, 
                                                   X = as.matrix(data.frame(Republican =df_bind_today_USA_na$Republican_z,Democrat =df_bind_today_USA_na$Democrat_z, Independent =df_bind_today_USA_na$Independent_z,Other =df_bind_today_USA_na$Other_z,Not_Close_To_Party =df_bind_today_USA_na$Not_close_z,Gender = df_bind_today_USA_na$gender_z ,Age = df_bind_today_USA_na$age_z , Education =df_bind_today_USA_na$education_z ,Income = df_bind_today_USA_na$inc_z ,Ideology =df_bind_today_USA_na$ideology_z, Number_Children = df_bind_today_USA_na$children_z,Lifestyle_Change = df_bind_today_USA_na$tec_z , State_Intervention = df_bind_today_USA_na$economy_z, Humans_Not_Cause= df_bind_today_USA_na$climate_scep_a2_z,CFC_Future= df_bind_today_USA_na$cfc_future_add_z,  Climate_Knowledge =df_bind_today_USA_na$priorknow_z ,Car_Use = df_bind_today_USA_na$car_z ,Meat_Consumption=df_bind_today_USA_na$meatcon_z , Perceived_Urgency=df_bind_today_USA_na$problem_today_z )),
                                                   treat = df_bind_today_USA_na$treatmentGroup_f,
                                                   scale.type = "TTX",
                                                   baseline.vec = c("Control"),
                                                   gibbs=1000, burnin=1000)

sparsereg::plot.sparsereg(out_response_1_direct_impact_self_n_USA, plot.one =1, main1 = "US: Dread - Selected Main Effects", xlabel = "Posterior Median of Standardized Effects")
sparsereg::summary.sparsereg(out_response_1_direct_impact_self_n_USA)

set.seed(1)

out_response_1_direct_impact_self_n_Germany <- sparsereg::sparsereg(y = df_bind_today_Germany_na$response_1_direct_impact_self_n, 
                                                       X = as.matrix(data.frame(AFD =df_bind_today_Germany_na$AFD_z,FDP =df_bind_today_Germany_na$FDP_z,Left =df_bind_today_Germany_na$Left_z, SPD =df_bind_today_Germany_na$SPD_z,Greens =df_bind_today_Germany_na$Greens_z,CDU_CSU =df_bind_today_Germany_na$CDU_CSU_z,Other =df_bind_today_Germany_na$Other_z,Not_Close_To_Party =df_bind_today_Germany_na$Not_close_z,Gender = df_bind_today_Germany_na$gender_z ,Age = df_bind_today_Germany_na$age_z , Education =df_bind_today_Germany_na$education_z ,Income = df_bind_today_Germany_na$inc_z ,Ideology =df_bind_today_Germany_na$ideology_z, Number_Children = df_bind_today_Germany_na$children_z,Lifestyle_Change = df_bind_today_Germany_na$tec_z ,State_Intervention = df_bind_today_Germany_na$economy_z , Humans_Not_Cause= df_bind_today_Germany_na$climate_scep_a2_z,CFC_Future= df_bind_today_Germany_na$cfc_future_add_z,  Climate_Knowledge =df_bind_today_Germany_na$priorknow_z ,Car_Use = df_bind_today_Germany_na$car_z ,Meat_Consumption=df_bind_today_Germany_na$meatcon_z , Perceived_Urgency=df_bind_today_Germany_na$problem_today_z )),
                                                       treat = df_bind_today_Germany_na$treatmentGroup_f,
                                                       scale.type = "TTX",
                                                       baseline.vec = c("Control"),
                                                       gibbs=1000, burnin=1000)


sparsereg::plot.sparsereg(out_response_1_direct_impact_self_n_Germany, plot.one =1, main1 = "Germany: Dread - Selected Main Effects", xlabel = "Posterior Median of Standardized Effects")
sparsereg::summary.sparsereg(out_response_1_direct_impact_self_n_Germany)

#As Robustness Check for sample including all respondents, also those that do not perceive climate change to be a problem today nor in future

set.seed(1)

table(df_bind_USA_na$response_1_direct_impact_self_n)

out_response_1_direct_impact_self_n_USA_all <- sparsereg::sparsereg(y = df_bind_USA_na$response_1_direct_impact_self_n, 
                                                       X = as.matrix(data.frame(Republican =df_bind_USA_na$Republican_z,Democrat =df_bind_USA_na$Democrat_z, Independent =df_bind_USA_na$Independent_z,Other =df_bind_USA_na$Other_z,Not_Close_To_Party =df_bind_USA_na$Not_close_z,Gender = df_bind_USA_na$gender_z ,Age = df_bind_USA_na$age_z , Education =df_bind_USA_na$education_z ,Income = df_bind_USA_na$inc_z ,Ideology =df_bind_USA_na$ideology_z, Number_Children = df_bind_USA_na$children_z,Lifestyle_Change = df_bind_USA_na$tec_z ,State_Intervention = df_bind_USA_na$economy_z , Humans_Not_Cause= df_bind_USA_na$climate_scep_a2_z,CFC_Immediate = df_bind_USA_na$cfc_immediate_add_z,CFC_Future= df_bind_USA_na$cfc_future_add_z,  Climate_Knowledge =df_bind_USA_na$priorknow_z ,Car_Use = df_bind_USA_na$car_z ,Meat_Consumption=df_bind_USA_na$meatcon_z , Perceived_Urgency=df_bind_USA_na$problem_z )),
                                                       treat = df_bind_USA_na$treatmentGroup_f,
                                                       scale.type = "TTX",
                                                       baseline.vec = c("Control"),
                                                       gibbs=1000, burnin=1000)

sparsereg::plot.sparsereg(out_response_1_direct_impact_self_n_USA_all, plot.one =1, main1 = "US: Dread - Selected Main Effects (Entire Sample)", xlabel = "Posterior Median of Standardized Effects")
sparsereg::summary.sparsereg(out_response_1_direct_impact_self_n_USA_all)

set.seed(1)

out_response_1_direct_impact_self_n_Germany_all <- sparsereg::sparsereg(y = df_bind_Germany_na$response_1_direct_impact_self_n, 
                                                           X = as.matrix(data.frame(AFD =df_bind_Germany_na$AFD_z,FDP =df_bind_Germany_na$FDP_z,Left =df_bind_Germany_na$Left_z, SPD =df_bind_Germany_na$SPD_z,Greens =df_bind_Germany_na$Greens_z,CDU_CSU =df_bind_Germany_na$CDU_CSU_z,Other =df_bind_Germany_na$Other_z,Not_Close_To_Party =df_bind_Germany_na$Not_close_z,Gender = df_bind_Germany_na$gender_z ,Age = df_bind_Germany_na$age_z , Education =df_bind_Germany_na$education_z ,Income = df_bind_Germany_na$inc_z ,Ideology =df_bind_Germany_na$ideology_z, Number_Children = df_bind_Germany_na$children_z,Lifestyle_Change = df_bind_Germany_na$tec_z ,State_Intervention = df_bind_Germany_na$economy_z , Humans_Not_Cause= df_bind_Germany_na$climate_scep_a2_z,CFC_Immediate = df_bind_Germany_na$cfc_immediate_add_z,CFC_Future= df_bind_Germany_na$cfc_future_add_z,  Climate_Knowledge =df_bind_Germany_na$priorknow_z ,Car_Use = df_bind_Germany_na$car_z ,Meat_Consumption=df_bind_Germany_na$meatcon_z , Perceived_Urgency=df_bind_Germany_na$problem_z )),
                                                           treat = df_bind_Germany_na$treatmentGroup_f,
                                                           scale.type = "TTX",
                                                           baseline.vec = c("Control"),
                                                           gibbs=1000, burnin=1000)

sparsereg::plot.sparsereg(out_response_1_direct_impact_self_n_Germany_all, plot.one =1, main1 = "Germany: Dread - Selected Main Effects (Entire Sample)", xlabel = "Posterior Median of Standardized Effects")
sparsereg::summary.sparsereg(out_response_1_direct_impact_self_n_Germany_all)


#Direct Concern for Other Countries
set.seed(1)

out_response_1_direct_impact_other_n_USA <- sparsereg::sparsereg(y = df_bind_today_USA_na$response_1_direct_impact_other_n, 
                                                                X = as.matrix(data.frame(Republican =df_bind_today_USA_na$Republican_z,Democrat =df_bind_today_USA_na$Democrat_z, Independent =df_bind_today_USA_na$Independent_z,Other =df_bind_today_USA_na$Other_z,Not_Close_To_Party =df_bind_today_USA_na$Not_close_z,Gender = df_bind_today_USA_na$gender_z ,Age = df_bind_today_USA_na$age_z , Education =df_bind_today_USA_na$education_z ,Income = df_bind_today_USA_na$inc_z ,Ideology =df_bind_today_USA_na$ideology_z, Number_Children = df_bind_today_USA_na$children_z,Lifestyle_Change = df_bind_today_USA_na$tec_z , State_Intervention = df_bind_today_USA_na$economy_z, Humans_Not_Cause= df_bind_today_USA_na$climate_scep_a2_z,CFC_Future= df_bind_today_USA_na$cfc_future_add_z,  Climate_Knowledge =df_bind_today_USA_na$priorknow_z ,Car_Use = df_bind_today_USA_na$car_z ,Meat_Consumption=df_bind_today_USA_na$meatcon_z , Perceived_Urgency=df_bind_today_USA_na$problem_today_z )),
                                                                treat = df_bind_today_USA_na$treatmentGroup_f,
                                                                scale.type = "TTX",
                                                                baseline.vec = c("Control"),
                                                                gibbs=1000, burnin=1000)

sparsereg::plot.sparsereg(out_response_1_direct_impact_other_n_USA, plot.one =1, main1 = "US: Dread - Selected Main Effects", xlabel = "Posterior Median of Standardized Effects")
sparsereg::summary.sparsereg(out_response_1_direct_impact_other_n_USA)

set.seed(1)

out_response_1_direct_impact_other_n_Germany <- sparsereg::sparsereg(y = df_bind_today_Germany_na$response_1_direct_impact_other_n, 
                                                                    X = as.matrix(data.frame(AFD =df_bind_today_Germany_na$AFD_z,FDP =df_bind_today_Germany_na$FDP_z,Left =df_bind_today_Germany_na$Left_z, SPD =df_bind_today_Germany_na$SPD_z,Greens =df_bind_today_Germany_na$Greens_z,CDU_CSU =df_bind_today_Germany_na$CDU_CSU_z,Other =df_bind_today_Germany_na$Other_z,Not_Close_To_Party =df_bind_today_Germany_na$Not_close_z,Gender = df_bind_today_Germany_na$gender_z ,Age = df_bind_today_Germany_na$age_z , Education =df_bind_today_Germany_na$education_z ,Income = df_bind_today_Germany_na$inc_z ,Ideology =df_bind_today_Germany_na$ideology_z, Number_Children = df_bind_today_Germany_na$children_z,Lifestyle_Change = df_bind_today_Germany_na$tec_z ,State_Intervention = df_bind_today_Germany_na$economy_z , Humans_Not_Cause= df_bind_today_Germany_na$climate_scep_a2_z,CFC_Future= df_bind_today_Germany_na$cfc_future_add_z,  Climate_Knowledge =df_bind_today_Germany_na$priorknow_z ,Car_Use = df_bind_today_Germany_na$car_z ,Meat_Consumption=df_bind_today_Germany_na$meatcon_z , Perceived_Urgency=df_bind_today_Germany_na$problem_today_z )),
                                                                    treat = df_bind_today_Germany_na$treatmentGroup_f,
                                                                    scale.type = "TTX",
                                                                    baseline.vec = c("Control"),
                                                                    gibbs=1000, burnin=1000)


sparsereg::plot.sparsereg(out_response_1_direct_impact_other_n_Germany, plot.one =1, main1 = "Germany: Dread - Selected Main Effects", xlabel = "Posterior Median of Standardized Effects")
sparsereg::summary.sparsereg(out_response_1_direct_impact_other_n_Germany)

#As Robustness Check for sample including all respondents, also those that do not perceive climate change to be a problem today nor in future

set.seed(1)

table(df_bind_USA_na$response_1_direct_impact_other_n)

out_response_1_direct_impact_other_n_USA_all <- sparsereg::sparsereg(y = df_bind_USA_na$response_1_direct_impact_other_n, 
                                                                    X = as.matrix(data.frame(Republican =df_bind_USA_na$Republican_z,Democrat =df_bind_USA_na$Democrat_z, Independent =df_bind_USA_na$Independent_z,Other =df_bind_USA_na$Other_z,Not_Close_To_Party =df_bind_USA_na$Not_close_z,Gender = df_bind_USA_na$gender_z ,Age = df_bind_USA_na$age_z , Education =df_bind_USA_na$education_z ,Income = df_bind_USA_na$inc_z ,Ideology =df_bind_USA_na$ideology_z, Number_Children = df_bind_USA_na$children_z,Lifestyle_Change = df_bind_USA_na$tec_z ,State_Intervention = df_bind_USA_na$economy_z , Humans_Not_Cause= df_bind_USA_na$climate_scep_a2_z,CFC_Immediate = df_bind_USA_na$cfc_immediate_add_z,CFC_Future= df_bind_USA_na$cfc_future_add_z,  Climate_Knowledge =df_bind_USA_na$priorknow_z ,Car_Use = df_bind_USA_na$car_z ,Meat_Consumption=df_bind_USA_na$meatcon_z , Perceived_Urgency=df_bind_USA_na$problem_z )),
                                                                    treat = df_bind_USA_na$treatmentGroup_f,
                                                                    scale.type = "TTX",
                                                                    baseline.vec = c("Control"),
                                                                    gibbs=1000, burnin=1000)

sparsereg::plot.sparsereg(out_response_1_direct_impact_other_n_USA_all, plot.one =1, main1 = "US: Dread - Selected Main Effects (Entire Sample)", xlabel = "Posterior Median of Standardized Effects")
sparsereg::summary.sparsereg(out_response_1_direct_impact_other_n_USA_all)

set.seed(1)

out_response_1_direct_impact_other_n_Germany_all <- sparsereg::sparsereg(y = df_bind_Germany_na$response_1_direct_impact_other_n, 
                                                                        X = as.matrix(data.frame(AFD =df_bind_Germany_na$AFD_z,FDP =df_bind_Germany_na$FDP_z,Left =df_bind_Germany_na$Left_z, SPD =df_bind_Germany_na$SPD_z,Greens =df_bind_Germany_na$Greens_z,CDU_CSU =df_bind_Germany_na$CDU_CSU_z,Other =df_bind_Germany_na$Other_z,Not_Close_To_Party =df_bind_Germany_na$Not_close_z,Gender = df_bind_Germany_na$gender_z ,Age = df_bind_Germany_na$age_z , Education =df_bind_Germany_na$education_z ,Income = df_bind_Germany_na$inc_z ,Ideology =df_bind_Germany_na$ideology_z, Number_Children = df_bind_Germany_na$children_z,Lifestyle_Change = df_bind_Germany_na$tec_z ,State_Intervention = df_bind_Germany_na$economy_z , Humans_Not_Cause= df_bind_Germany_na$climate_scep_a2_z,CFC_Immediate = df_bind_Germany_na$cfc_immediate_add_z,CFC_Future= df_bind_Germany_na$cfc_future_add_z,  Climate_Knowledge =df_bind_Germany_na$priorknow_z ,Car_Use = df_bind_Germany_na$car_z ,Meat_Consumption=df_bind_Germany_na$meatcon_z , Perceived_Urgency=df_bind_Germany_na$problem_z )),
                                                                        treat = df_bind_Germany_na$treatmentGroup_f,
                                                                        scale.type = "TTX",
                                                                        baseline.vec = c("Control"),
                                                                        gibbs=1000, burnin=1000)

sparsereg::plot.sparsereg(out_response_1_direct_impact_other_n_Germany_all, plot.one =1, main1 = "Germany: Dread - Selected Main Effects (Entire Sample)", xlabel = "Posterior Median of Standardized Effects")
sparsereg::summary.sparsereg(out_response_1_direct_impact_other_n_Germany_all)

#General Mitigation
set.seed(1)

out_response_1_mitigation_n_USA <- sparsereg::sparsereg(y = df_bind_today_USA_na$response_1_mitigation_n, 
                                             X = as.matrix(data.frame(Dread = df_bind_today_USA_na$response_1_dread_z,Republican =df_bind_today_USA_na$Republican_z,Democrat =df_bind_today_USA_na$Democrat_z, Independent =df_bind_today_USA_na$Independent_z,Other =df_bind_today_USA_na$Other_z,Not_Close_To_Party =df_bind_today_USA_na$Not_close_z,Gender = df_bind_today_USA_na$gender_z ,Age = df_bind_today_USA_na$age_z , Education =df_bind_today_USA_na$education_z ,Income = df_bind_today_USA_na$inc_z ,Ideology =df_bind_today_USA_na$ideology_z, Number_Children = df_bind_today_USA_na$children_z,Lifestyle_Change = df_bind_today_USA_na$tec_z , State_Intervention = df_bind_today_USA_na$economy_z, Humans_Not_Cause= df_bind_today_USA_na$climate_scep_a2_z,CFC_Future= df_bind_today_USA_na$cfc_future_add_z,  Climate_Knowledge =df_bind_today_USA_na$priorknow_z ,Car_Use = df_bind_today_USA_na$car_z ,Meat_Consumption=df_bind_today_USA_na$meatcon_z , Perceived_Urgency=df_bind_today_USA_na$problem_today_z )),
                                             treat = df_bind_today_USA_na$treatmentGroup_f,
                                             scale.type = "TTX",
                                             baseline.vec = c("Control"),
                                             gibbs=1000, burnin=1000)

sparsereg::plot.sparsereg(out_response_1_mitigation_n_USA, plot.one =1, main1 = "US: General Mitigation - Selected Main Effects", xlabel = "Posterior Median of Standardized Effects")
sparsereg::summary.sparsereg(out_response_1_mitigation_n_USA)

set.seed(1)

out_response_1_mitigation_n_USA_concern <- sparsereg::sparsereg(y = df_bind_today_USA_na$response_1_mitigation_n, 
                                                        X = as.matrix(data.frame(Personal_Concern =df_bind_today_USA_na$response_1_direct_impact_self_z,Country_Concern =df_bind_today_USA_na$response_1_direct_impact_USA_z,Other_Country_Concern =df_bind_today_USA_na$response_1_direct_impact_other_z,Dread = df_bind_today_USA_na$response_1_dread_z,Republican =df_bind_today_USA_na$Republican_z,Democrat =df_bind_today_USA_na$Democrat_z, Independent =df_bind_today_USA_na$Independent_z,Other =df_bind_today_USA_na$Other_z,Not_Close_To_Party =df_bind_today_USA_na$Not_close_z,Gender = df_bind_today_USA_na$gender_z ,Age = df_bind_today_USA_na$age_z , Education =df_bind_today_USA_na$education_z ,Income = df_bind_today_USA_na$inc_z ,Ideology =df_bind_today_USA_na$ideology_z, Number_Children = df_bind_today_USA_na$children_z,Lifestyle_Change = df_bind_today_USA_na$tec_z , State_Intervention = df_bind_today_USA_na$economy_z, Humans_Not_Cause= df_bind_today_USA_na$climate_scep_a2_z,CFC_Future= df_bind_today_USA_na$cfc_future_add_z,  Climate_Knowledge =df_bind_today_USA_na$priorknow_z ,Car_Use = df_bind_today_USA_na$car_z ,Meat_Consumption=df_bind_today_USA_na$meatcon_z , Perceived_Urgency=df_bind_today_USA_na$problem_today_z )),
                                                        treat = df_bind_today_USA_na$treatmentGroup_f,
                                                        scale.type = "TTX",
                                                        baseline.vec = c("Control"),
                                                        gibbs=1000, burnin=1000)

sparsereg::plot.sparsereg(out_response_1_mitigation_n_USA_concern, plot.one =1, main1 = "US: General Mitigation - Selected Main Effects", xlabel = "Posterior Median of Standardized Effects")
sparsereg::summary.sparsereg(out_response_1_mitigation_n_USA_concern)

set.seed(1)

out_response_1_mitigation_n_USA_withoutdread <- sparsereg::sparsereg(y = df_bind_today_USA_na$response_1_mitigation_n, 
                                                        X = as.matrix(data.frame(Republican =df_bind_today_USA_na$Republican_z,Democrat =df_bind_today_USA_na$Democrat_z, Independent =df_bind_today_USA_na$Independent_z,Other =df_bind_today_USA_na$Other_z,Not_Close_To_Party =df_bind_today_USA_na$Not_close_z,Gender = df_bind_today_USA_na$gender_z ,Age = df_bind_today_USA_na$age_z , Education =df_bind_today_USA_na$education_z ,Income = df_bind_today_USA_na$inc_z ,Ideology =df_bind_today_USA_na$ideology_z, Number_Children = df_bind_today_USA_na$children_z,Lifestyle_Change = df_bind_today_USA_na$tec_z , State_Intervention = df_bind_today_USA_na$economy_z, Humans_Not_Cause= df_bind_today_USA_na$climate_scep_a2_z,CFC_Future= df_bind_today_USA_na$cfc_future_add_z,  Climate_Knowledge =df_bind_today_USA_na$priorknow_z ,Car_Use = df_bind_today_USA_na$car_z ,Meat_Consumption=df_bind_today_USA_na$meatcon_z , Perceived_Urgency=df_bind_today_USA_na$problem_today_z )),
                                                        treat = df_bind_today_USA_na$treatmentGroup_f,
                                                        scale.type = "TTX",
                                                        baseline.vec = c("Control"),
                                                        gibbs=1000, burnin=1000)

sparsereg::plot.sparsereg(out_response_1_mitigation_n_USA_withoutdread, plot.one =1, main1 = "US: General Mitigation - Selected Main Effects", xlabel = "Posterior Median of Standardized Effects")
sparsereg::summary.sparsereg(out_response_1_mitigation_n_USA_withoutdread)

set.seed(1)

out_response_1_mitigation_n_Germany <- sparsereg::sparsereg(y = df_bind_today_Germany_na$response_1_mitigation_n, 
                                             X = as.matrix(data.frame(Dread = df_bind_today_Germany_na$response_1_dread_z,AFD =df_bind_today_Germany_na$AFD_z,FDP =df_bind_today_Germany_na$FDP_z,Left =df_bind_today_Germany_na$Left_z, SPD =df_bind_today_Germany_na$SPD_z,Greens =df_bind_today_Germany_na$Greens_z,CDU_CSU =df_bind_today_Germany_na$CDU_CSU_z,Other =df_bind_today_Germany_na$Other_z,Not_Close_To_Party =df_bind_today_Germany_na$Not_close_z,Gender = df_bind_today_Germany_na$gender_z ,Age = df_bind_today_Germany_na$age_z , Education =df_bind_today_Germany_na$education_z ,Income = df_bind_today_Germany_na$inc_z ,Ideology =df_bind_today_Germany_na$ideology_z, Number_Children = df_bind_today_Germany_na$children_z,Lifestyle_Change = df_bind_today_Germany_na$tec_z ,State_Intervention = df_bind_today_Germany_na$economy_z , Humans_Not_Cause= df_bind_today_Germany_na$climate_scep_a2_z,CFC_Future= df_bind_today_Germany_na$cfc_future_add_z,  Climate_Knowledge =df_bind_today_Germany_na$priorknow_z ,Car_Use = df_bind_today_Germany_na$car_z ,Meat_Consumption=df_bind_today_Germany_na$meatcon_z , Perceived_Urgency=df_bind_today_Germany_na$problem_today_z )),
                                             treat = df_bind_today_Germany_na$treatmentGroup_f,
                                             scale.type = "TTX",
                                             baseline.vec = c("Control"),
                                             gibbs=1000, burnin=1000)


sparsereg::plot.sparsereg(out_response_1_mitigation_n_Germany, plot.one =1, main1 = "Germany: General Mitigation - Selected Main Effects", xlabel = "Posterior Median of Standardized Effects")
sparsereg::summary.sparsereg(out_response_1_mitigation_n_Germany)

set.seed(1)

out_response_1_mitigation_n_Germany_concern <- sparsereg::sparsereg(y = df_bind_today_Germany_na$response_1_mitigation_n, 
                                                            X = as.matrix(data.frame(Personal_Concern =df_bind_today_Germany_na$response_1_direct_impact_self_z,Country_Concern =df_bind_today_Germany_na$response_1_direct_impact_Germany_z, Other_Country_Concern =df_bind_today_Germany_na$response_1_direct_impact_other_z,Dread = df_bind_today_Germany_na$response_1_dread_z,AFD =df_bind_today_Germany_na$AFD_z,FDP =df_bind_today_Germany_na$FDP_z,Left =df_bind_today_Germany_na$Left_z, SPD =df_bind_today_Germany_na$SPD_z,Greens =df_bind_today_Germany_na$Greens_z,CDU_CSU =df_bind_today_Germany_na$CDU_CSU_z,Other =df_bind_today_Germany_na$Other_z,Not_Close_To_Party =df_bind_today_Germany_na$Not_close_z,Gender = df_bind_today_Germany_na$gender_z ,Age = df_bind_today_Germany_na$age_z , Education =df_bind_today_Germany_na$education_z ,Income = df_bind_today_Germany_na$inc_z ,Ideology =df_bind_today_Germany_na$ideology_z, Number_Children = df_bind_today_Germany_na$children_z,Lifestyle_Change = df_bind_today_Germany_na$tec_z ,State_Intervention = df_bind_today_Germany_na$economy_z , Humans_Not_Cause= df_bind_today_Germany_na$climate_scep_a2_z,CFC_Future= df_bind_today_Germany_na$cfc_future_add_z,  Climate_Knowledge =df_bind_today_Germany_na$priorknow_z ,Car_Use = df_bind_today_Germany_na$car_z ,Meat_Consumption=df_bind_today_Germany_na$meatcon_z , Perceived_Urgency=df_bind_today_Germany_na$problem_today_z )),
                                                            treat = df_bind_today_Germany_na$treatmentGroup_f,
                                                            scale.type = "TTX",
                                                            baseline.vec = c("Control"),
                                                            gibbs=1000, burnin=1000)


sparsereg::plot.sparsereg(out_response_1_mitigation_n_Germany_concern, plot.one =1, main1 = "Germany: General Mitigation - Selected Main Effects", xlabel = "Posterior Median of Standardized Effects")
sparsereg::summary.sparsereg(out_response_1_mitigation_n_Germany_concern)

set.seed(1)

out_response_1_mitigation_n_Germany_withoutdread <- sparsereg::sparsereg(y = df_bind_today_Germany_na$response_1_mitigation_n, 
                                                            X = as.matrix(data.frame(AFD =df_bind_today_Germany_na$AFD_z,FDP =df_bind_today_Germany_na$FDP_z,Left =df_bind_today_Germany_na$Left_z, SPD =df_bind_today_Germany_na$SPD_z,Greens =df_bind_today_Germany_na$Greens_z,CDU_CSU =df_bind_today_Germany_na$CDU_CSU_z,Other =df_bind_today_Germany_na$Other_z,Not_Close_To_Party =df_bind_today_Germany_na$Not_close_z,Gender = df_bind_today_Germany_na$gender_z ,Age = df_bind_today_Germany_na$age_z , Education =df_bind_today_Germany_na$education_z ,Income = df_bind_today_Germany_na$inc_z ,Ideology =df_bind_today_Germany_na$ideology_z, Number_Children = df_bind_today_Germany_na$children_z,Lifestyle_Change = df_bind_today_Germany_na$tec_z ,State_Intervention = df_bind_today_Germany_na$economy_z , Humans_Not_Cause= df_bind_today_Germany_na$climate_scep_a2_z,CFC_Future= df_bind_today_Germany_na$cfc_future_add_z,  Climate_Knowledge =df_bind_today_Germany_na$priorknow_z ,Car_Use = df_bind_today_Germany_na$car_z ,Meat_Consumption=df_bind_today_Germany_na$meatcon_z , Perceived_Urgency=df_bind_today_Germany_na$problem_today_z )),
                                                            treat = df_bind_today_Germany_na$treatmentGroup_f,
                                                            scale.type = "TTX",
                                                            baseline.vec = c("Control"),
                                                            gibbs=1000, burnin=1000)


sparsereg::plot.sparsereg(out_response_1_mitigation_n_Germany_withoutdread, plot.one =1, main1 = "Germany: General Mitigation - Selected Main Effects", xlabel = "Posterior Median of Standardized Effects")
sparsereg::summary.sparsereg(out_response_1_mitigation_n_Germany_withoutdread)

#As Robustness Check for sample including all respondents, also those that do not perceive climate change to be a problem today nor in future

set.seed(1)

out_response_1_mitigation_n_USA_all <- sparsereg::sparsereg(y = df_bind_USA_na$response_1_mitigation_n, 
                                                        X = as.matrix(data.frame(Dread = df_bind_USA_na$response_1_dread_z,Republican =df_bind_USA_na$Republican_z,Democrat =df_bind_USA_na$Democrat_z, Independent =df_bind_USA_na$Independent_z,Other =df_bind_USA_na$Other_z,Not_Close_To_Party =df_bind_USA_na$Not_close_z,Gender = df_bind_USA_na$gender_z ,Age = df_bind_USA_na$age_z , Education =df_bind_USA_na$education_z ,Income = df_bind_USA_na$inc_z ,Ideology =df_bind_USA_na$ideology_z, Number_Children = df_bind_USA_na$children_z,Lifestyle_Change = df_bind_USA_na$tec_z ,State_Intervention = df_bind_USA_na$economy_z , Humans_Not_Cause= df_bind_USA_na$climate_scep_a2_z,CFC_Immediate = df_bind_USA_na$cfc_immediate_add_z,CFC_Future= df_bind_USA_na$cfc_future_add_z,  Climate_Knowledge =df_bind_USA_na$priorknow_z ,Car_Use = df_bind_USA_na$car_z ,Meat_Consumption=df_bind_USA_na$meatcon_z , Perceived_Urgency=df_bind_USA_na$problem_z )),
                                                        treat = df_bind_USA_na$treatmentGroup_f,
                                                        scale.type = "TTX",
                                                        baseline.vec = c("Control"),
                                                        gibbs=1000, burnin=1000)

sparsereg::plot.sparsereg(out_response_1_mitigation_n_USA_all, plot.one =1, main1 = "US: General Mitigation - Selected Main Effects (Entire Sample)", xlabel = "Posterior Median of Standardized Effects")
sparsereg::summary.sparsereg(out_response_1_mitigation_n_USA_all)

set.seed(1)

out_response_1_mitigation_n_Germany_all <- sparsereg::sparsereg(y = df_bind_Germany_na$response_1_mitigation_n, 
                                                            X = as.matrix(data.frame(Dread = df_bind_Germany_na$response_1_dread_z,AFD =df_bind_Germany_na$AFD_z,FDP =df_bind_Germany_na$FDP_z,Left =df_bind_Germany_na$Left_z, SPD =df_bind_Germany_na$SPD_z,Greens =df_bind_Germany_na$Greens_z,CDU_CSU =df_bind_Germany_na$CDU_CSU_z,Other =df_bind_Germany_na$Other_z,Not_Close_To_Party =df_bind_Germany_na$Not_close_z,Gender = df_bind_Germany_na$gender_z ,Age = df_bind_Germany_na$age_z , Education =df_bind_Germany_na$education_z ,Income = df_bind_Germany_na$inc_z ,Ideology =df_bind_Germany_na$ideology_z, Number_Children = df_bind_Germany_na$children_z,Lifestyle_Change = df_bind_Germany_na$tec_z ,State_Intervention = df_bind_Germany_na$economy_z , Humans_Not_Cause= df_bind_Germany_na$climate_scep_a2_z,CFC_Immediate = df_bind_Germany_na$cfc_immediate_add_z,CFC_Future= df_bind_Germany_na$cfc_future_add_z,  Climate_Knowledge =df_bind_Germany_na$priorknow_z ,Car_Use = df_bind_Germany_na$car_z ,Meat_Consumption=df_bind_Germany_na$meatcon_z , Perceived_Urgency=df_bind_Germany_na$problem_z )),
                                                            treat = df_bind_Germany_na$treatmentGroup_f,
                                                            scale.type = "TTX",
                                                            baseline.vec = c("Control"),
                                                            gibbs=1000, burnin=1000)

sparsereg::plot.sparsereg(out_response_1_mitigation_n_Germany_all, plot.one =1, main1 = "Germany: General Mitigation - Selected Main Effects (Entire Sample)", xlabel = "Posterior Median of Standardized Effects")
sparsereg::summary.sparsereg(out_response_1_mitigation_n_Germany_all)

#Demand-Side Mitigation

set.seed(1)

out_less_behave_n_USA <- sparsereg::sparsereg(y = df_bind_today_USA_na$less_behave_n, 
                                                        X = as.matrix(data.frame(Dread = df_bind_today_USA_na$response_1_dread_z,Republican =df_bind_today_USA_na$Republican_z,Democrat =df_bind_today_USA_na$Democrat_z, Independent =df_bind_today_USA_na$Independent_z,Other =df_bind_today_USA_na$Other_z,Not_Close_To_Party =df_bind_today_USA_na$Not_close_z,Gender = df_bind_today_USA_na$gender_z ,Age = df_bind_today_USA_na$age_z , Education =df_bind_today_USA_na$education_z ,Income = df_bind_today_USA_na$inc_z ,Ideology =df_bind_today_USA_na$ideology_z, Number_Children = df_bind_today_USA_na$children_z,Lifestyle_Change = df_bind_today_USA_na$tec_z , State_Intervention = df_bind_today_USA_na$economy_z, Humans_Not_Cause= df_bind_today_USA_na$climate_scep_a2_z,CFC_Future= df_bind_today_USA_na$cfc_future_add_z,  Climate_Knowledge =df_bind_today_USA_na$priorknow_z ,Car_Use = df_bind_today_USA_na$car_z ,Meat_Consumption=df_bind_today_USA_na$meatcon_z , Perceived_Urgency=df_bind_today_USA_na$problem_today_z )),
                                                        treat = df_bind_today_USA_na$treatmentGroup_f,
                                                        scale.type = "TTX",
                                                        baseline.vec = c("Control"),
                                                        gibbs=1000, burnin=1000)

sparsereg::plot.sparsereg(out_less_behave_n_USA, plot.one =1, main1 = "US: Demand-Side Mitigation - Selected Main Effects", xlabel = "Posterior Median of Standardized Effects")
sparsereg::summary.sparsereg(out_less_behave_n_USA)

set.seed(1)

out_less_behave_n_USA_concern <- sparsereg::sparsereg(y = df_bind_today_USA_na$less_behave_n, 
                                              X = as.matrix(data.frame(Personal_Concern =df_bind_today_USA_na$response_1_direct_impact_self_z,Country_Concern =df_bind_today_USA_na$response_1_direct_impact_USA_z,Other_Country_Concern =df_bind_today_USA_na$response_1_direct_impact_other_z, Dread = df_bind_today_USA_na$response_1_dread_z,Republican =df_bind_today_USA_na$Republican_z,Democrat =df_bind_today_USA_na$Democrat_z, Independent =df_bind_today_USA_na$Independent_z,Other =df_bind_today_USA_na$Other_z,Not_Close_To_Party =df_bind_today_USA_na$Not_close_z,Gender = df_bind_today_USA_na$gender_z ,Age = df_bind_today_USA_na$age_z , Education =df_bind_today_USA_na$education_z ,Income = df_bind_today_USA_na$inc_z ,Ideology =df_bind_today_USA_na$ideology_z, Number_Children = df_bind_today_USA_na$children_z,Lifestyle_Change = df_bind_today_USA_na$tec_z , State_Intervention = df_bind_today_USA_na$economy_z, Humans_Not_Cause= df_bind_today_USA_na$climate_scep_a2_z,CFC_Future= df_bind_today_USA_na$cfc_future_add_z,  Climate_Knowledge =df_bind_today_USA_na$priorknow_z ,Car_Use = df_bind_today_USA_na$car_z ,Meat_Consumption=df_bind_today_USA_na$meatcon_z , Perceived_Urgency=df_bind_today_USA_na$problem_today_z )),
                                              treat = df_bind_today_USA_na$treatmentGroup_f,
                                              scale.type = "TTX",
                                              baseline.vec = c("Control"),
                                              gibbs=1000, burnin=1000)

sparsereg::plot.sparsereg(out_less_behave_n_USA_concern, plot.one =1, main1 = "US: Demand-Side Mitigation - Selected Main Effects", xlabel = "Posterior Median of Standardized Effects")
sparsereg::summary.sparsereg(out_less_behave_n_USA_concern)

set.seed(1)

out_less_behave_n_Germany <- sparsereg::sparsereg(y = df_bind_today_Germany_na$less_behave_n, 
                                                            X = as.matrix(data.frame(Dread = df_bind_today_Germany_na$response_1_dread_z,AFD =df_bind_today_Germany_na$AFD_z,FDP =df_bind_today_Germany_na$FDP_z,Left =df_bind_today_Germany_na$Left_z, SPD =df_bind_today_Germany_na$SPD_z,Greens =df_bind_today_Germany_na$Greens_z,CDU_CSU =df_bind_today_Germany_na$CDU_CSU_z,Other =df_bind_today_Germany_na$Other_z,Not_Close_To_Party =df_bind_today_Germany_na$Not_close_z,Gender = df_bind_today_Germany_na$gender_z ,Age = df_bind_today_Germany_na$age_z , Education =df_bind_today_Germany_na$education_z ,Income = df_bind_today_Germany_na$inc_z ,Ideology =df_bind_today_Germany_na$ideology_z, Number_Children = df_bind_today_Germany_na$children_z,Lifestyle_Change = df_bind_today_Germany_na$tec_z ,State_Intervention = df_bind_today_Germany_na$economy_z , Humans_Not_Cause= df_bind_today_Germany_na$climate_scep_a2_z,CFC_Future= df_bind_today_Germany_na$cfc_future_add_z,  Climate_Knowledge =df_bind_today_Germany_na$priorknow_z ,Car_Use = df_bind_today_Germany_na$car_z ,Meat_Consumption=df_bind_today_Germany_na$meatcon_z , Perceived_Urgency=df_bind_today_Germany_na$problem_today_z )),
                                                            treat = df_bind_today_Germany_na$treatmentGroup_f,
                                                            scale.type = "TTX",
                                                            baseline.vec = c("Control"),
                                                            gibbs=1000, burnin=1000)


sparsereg::plot.sparsereg(out_less_behave_n_Germany, plot.one =1, main1 = "Germany: Demand-Side Mitigation - Selected Main Effects", xlabel = "Posterior Median of Standardized Effects")
sparsereg::summary.sparsereg(out_less_behave_n_Germany)

set.seed(1)

out_less_behave_n_Germany_concern <- sparsereg::sparsereg(y = df_bind_today_Germany_na$less_behave_n, 
                                                  X = as.matrix(data.frame(Personal_Concern =df_bind_today_Germany_na$response_1_direct_impact_self_z,Country_Concern =df_bind_today_Germany_na$response_1_direct_impact_Germany_z, Other_Country_Concern =df_bind_today_Germany_na$response_1_direct_impact_other_z,Dread = df_bind_today_Germany_na$response_1_dread_z,AFD =df_bind_today_Germany_na$AFD_z,FDP =df_bind_today_Germany_na$FDP_z,Left =df_bind_today_Germany_na$Left_z, SPD =df_bind_today_Germany_na$SPD_z,Greens =df_bind_today_Germany_na$Greens_z,CDU_CSU =df_bind_today_Germany_na$CDU_CSU_z,Other =df_bind_today_Germany_na$Other_z,Not_Close_To_Party =df_bind_today_Germany_na$Not_close_z,Gender = df_bind_today_Germany_na$gender_z ,Age = df_bind_today_Germany_na$age_z , Education =df_bind_today_Germany_na$education_z ,Income = df_bind_today_Germany_na$inc_z ,Ideology =df_bind_today_Germany_na$ideology_z, Number_Children = df_bind_today_Germany_na$children_z,Lifestyle_Change = df_bind_today_Germany_na$tec_z ,State_Intervention = df_bind_today_Germany_na$economy_z , Humans_Not_Cause= df_bind_today_Germany_na$climate_scep_a2_z,CFC_Future= df_bind_today_Germany_na$cfc_future_add_z,  Climate_Knowledge =df_bind_today_Germany_na$priorknow_z ,Car_Use = df_bind_today_Germany_na$car_z ,Meat_Consumption=df_bind_today_Germany_na$meatcon_z , Perceived_Urgency=df_bind_today_Germany_na$problem_today_z )),
                                                  treat = df_bind_today_Germany_na$treatmentGroup_f,
                                                  scale.type = "TTX",
                                                  baseline.vec = c("Control"),
                                                  gibbs=1000, burnin=1000)


sparsereg::plot.sparsereg(out_less_behave_n_Germany_concern, plot.one =1, main1 = "Germany: Demand-Side Mitigation - Selected Main Effects", xlabel = "Posterior Median of Standardized Effects")
sparsereg::summary.sparsereg(out_less_behave_n_Germany_concern)

#As Robustness Check for sample including all respondents, also those that do not perceive climate change to be a problem today nor in future

set.seed(1)

out_less_behave_n_USA_all <- sparsereg::sparsereg(y = df_bind_USA_na$less_behave_n, 
                                                            X = as.matrix(data.frame(Dread = df_bind_USA_na$response_1_dread_z,Republican =df_bind_USA_na$Republican_z,Democrat =df_bind_USA_na$Democrat_z, Independent =df_bind_USA_na$Independent_z,Other =df_bind_USA_na$Other_z,Not_Close_To_Party =df_bind_USA_na$Not_close_z,Gender = df_bind_USA_na$gender_z ,Age = df_bind_USA_na$age_z , Education =df_bind_USA_na$education_z ,Income = df_bind_USA_na$inc_z ,Ideology =df_bind_USA_na$ideology_z, Number_Children = df_bind_USA_na$children_z,Lifestyle_Change = df_bind_USA_na$tec_z ,State_Intervention = df_bind_USA_na$economy_z , Humans_Not_Cause= df_bind_USA_na$climate_scep_a2_z,CFC_Immediate = df_bind_USA_na$cfc_immediate_add_z,CFC_Future= df_bind_USA_na$cfc_future_add_z,  Climate_Knowledge =df_bind_USA_na$priorknow_z ,Car_Use = df_bind_USA_na$car_z ,Meat_Consumption=df_bind_USA_na$meatcon_z , Perceived_Urgency=df_bind_USA_na$problem_z )),
                                                            treat = df_bind_USA_na$treatmentGroup_f,
                                                            scale.type = "TTX",
                                                            baseline.vec = c("Control"),
                                                            gibbs=1000, burnin=1000)

sparsereg::plot.sparsereg(out_less_behave_n_USA_all, plot.one =1, main1 = "US: Demand-Side Mitigation - Selected Main Effects (Entire Sample)", xlabel = "Posterior Median of Standardized Effects")
sparsereg::summary.sparsereg(out_less_behave_n_USA_all)

set.seed(1)

out_less_behave_n_Germany_all <- sparsereg::sparsereg(y = df_bind_Germany_na$less_behave_n, 
                                                                X = as.matrix(data.frame(Dread = df_bind_Germany_na$response_1_dread_z,AFD =df_bind_Germany_na$AFD_z,FDP =df_bind_Germany_na$FDP_z,Left =df_bind_Germany_na$Left_z, SPD =df_bind_Germany_na$SPD_z,Greens =df_bind_Germany_na$Greens_z,CDU_CSU =df_bind_Germany_na$CDU_CSU_z,Other =df_bind_Germany_na$Other_z,Not_Close_To_Party =df_bind_Germany_na$Not_close_z,Gender = df_bind_Germany_na$gender_z ,Age = df_bind_Germany_na$age_z , Education =df_bind_Germany_na$education_z ,Income = df_bind_Germany_na$inc_z ,Ideology =df_bind_Germany_na$ideology_z, Number_Children = df_bind_Germany_na$children_z,Lifestyle_Change = df_bind_Germany_na$tec_z ,State_Intervention = df_bind_Germany_na$economy_z , Humans_Not_Cause= df_bind_Germany_na$climate_scep_a2_z,CFC_Immediate = df_bind_Germany_na$cfc_immediate_add_z,CFC_Future= df_bind_Germany_na$cfc_future_add_z,  Climate_Knowledge =df_bind_Germany_na$priorknow_z ,Car_Use = df_bind_Germany_na$car_z ,Meat_Consumption=df_bind_Germany_na$meatcon_z , Perceived_Urgency=df_bind_Germany_na$problem_z )),
                                                                treat = df_bind_Germany_na$treatmentGroup_f,
                                                                scale.type = "TTX",
                                                                baseline.vec = c("Control"),
                                                                gibbs=1000, burnin=1000)

sparsereg::plot.sparsereg(out_less_behave_n_Germany_all, plot.one =1, main1 = "Germany: Demand-Side Mitigation - Selected Main Effects (Entire Sample)", xlabel = "Posterior Median of Standardized Effects")
sparsereg::summary.sparsereg(out_less_behave_n_Germany_all)

table(df_bind_Germany_na$less_behave_n)

################ Final Figures ######################


#Plot Factual Manipulation Check--------

table(df_bind_today_USA$comp)
207/(3243+207)

table(df_bind_today_Germany$comp)
197/(3419+197)
table(df_bind$country)


Fig2 <- ggplot(tgc_comp, aes(x=country, group =problem_today_bin, y=comp_n, fill=problem_today_bin)) + 
  geom_bar(position=position_dodge(), stat="identity",
           colour="black", # Use black outlines,
           size=.3) +      # Thinner lines
  geom_errorbar(aes(ymin=comp_n-ci, ymax=comp_n+ci),
                size=1,    # Thinner lines
                width=.2,
                position=position_dodge(.9), colour="black") +theme_bw()+
  scale_fill_manual("problem_today_bin", values = c("No problem today" = "#78ABC8", "Problem today" = "#41698C"))+
  # scale_colour_manual("problem_today_bin", values = c("No problem today" = "#78ABC8", "Problem today" = "#41698C"))+guides(fill=FALSE)+
  facet_grid(.~country, scales ="free")+
  xlab("") +
  ylab("") +
  # scale_colour_hue(name="high_self_trans_sd",    # Legend label, use darker colors
  #                  breaks=c("high", "low"),
  #                  labels=c("High Self-Transcendent Values", "Low Self-Transcendent Values"),
  #                  l=40) +                    # Use darker colors, lightness=40
  # # expand_limits(y=0) +                        # Expand y range
  #scale_y_continuous(breaks=0:20*4) +         # Set tick every 4
  theme_bw() +
  
  #scale_fill_hue(name="Treatment", # Legend label, use darker colors
  #breaks=c("OJ", "VC"),
  #labels=c("Orange juice", "Ascorbic acid")) +
  ggtitle("Factual Manipulation Check Success Rate by Temporal Problem Perception") +
  scale_y_continuous(labels = percent)+
  #scale_y_continuous(breaks =c(0,2), labels = c("False", "True"))
  #scale_fill_discrete("")+
  theme(plot.title = element_text(size = 24, face = "bold"),legend.title =element_blank(), legend.text = element_text(size = 22, face = "bold"),axis.text.x =element_text(size=22, face ="bold"),axis.text.y =element_text(size=22, face ="bold"),strip.text.x = element_text(size=22, face ="bold"),strip.text.y = element_text(size=22, face ="bold"), axis.title.y = element_text(size = 22, face ="bold"))+
  theme(legend.justification=c(1,0),
        legend.position="bottom") 

ggsave("Fig2.jpeg",Fig2, height = 14, width = 14*2,dpi = 150)

#Plot OLS Main Effects--------

#Figure - Main Effects on Dread Outcome

mydf_F2_dread_US <- data.frame(
  coef = c(coef(summary(F2_main_dread_US.ols))[2],coef(summary(F2_main_dread_US.ols))[3], coef(summary(F2_main_dread_US.ols))[4], coef(summary(F2_main_dread_US.ols ))[5]),
  Treatment = factor(c("treatmentGroup_fShort", "treatmentGroup_fLong", "treatmentGroup_fShort-\nContext", "treatmentGroup_fLong-\nContext")),
  se = c(coef(summary(F2_main_dread_US.ols ))[2,2], coef(summary(F2_main_dread_US.ols))[3,2], coef(summary(F2_main_dread_US.ols))[4,2], coef(summary(F2_main_dread_US.ols))[5,2]),
  DV = factor(rep(c("Dread"), 4)),
  country = "US")

mydf_F2_dread_Germany <- data.frame(
  coef = c(coef(summary(F2_main_dread_DE.ols))[2],coef(summary(F2_main_dread_DE.ols))[3], coef(summary(F2_main_dread_DE.ols))[4], coef(summary(F2_main_dread_DE.ols ))[5]),
  Treatment = factor(c("treatmentGroup_fShort", "treatmentGroup_fLong", "treatmentGroup_fShort-\nContext", "treatmentGroup_fLong-\nContext")),
  se = c(coef(summary(F2_main_dread_DE.ols ))[2,2], coef(summary(F2_main_dread_DE.ols))[3,2], coef(summary(F2_main_dread_DE.ols))[4,2], coef(summary(F2_main_dread_DE.ols))[5,2]),
  DV = factor(rep(c("Dread"), 4)),
  country = "Germany")

b <- rbind(mydf_F2_dread_Germany,mydf_F2_dread_US)
b$Treatment <- plyr::mapvalues(b$Treatment, c("treatmentGroup_fShort", "treatmentGroup_fLong", "treatmentGroup_fShort-\nContext", "treatmentGroup_fLong-\nContext"), c("Short", "Long", "Short-\nContext", "Long-\nContext"))

b <- b[, names(b) %in% c('Treatment', 'country', 'coef', 'DV', 'se')]

b$Treatment <- mapvalues(b$Treatment, from =c("Short", "Long", "Short-\nContext","Long-\nContext"), to = c("High\nUrgency", "Low\nUrgency", "High\nUrgency + Context","Low\nUrgency + Context"))

F2_main_dread_ols <- ggplot(b, aes(x = Treatment, color = country, group =country, y =coef)) + 
  geom_errorbar(aes(ymin=coef - 1.96*se, ymax=coef + 1.96*se), size =3, width=.2, position=pd) +
  #geom_line(position=pd, size =2) +
  geom_point(position=pd, size=3, shape=21, fill="white")+ # 21 is filled circle +
  geom_hline(yintercept = 0, lty="dashed")+
  facet_grid(DV~country, scales ="free")+
  #ylim(c(-0.25,0.75))+
  xlab("") +
  ylab("Average Treatment Effects") +
  ggtitle("Effects of Temporal Framing on Feelings of Dread") +
  theme_bw() +
  theme(legend.justification=c(1,0),
        legend.position="")      + 
  theme(plot.title = element_text(size = 34, face = "bold"),legend.title =element_blank(), legend.text = element_text(size = 30, face = "bold"),axis.text.x =element_text(size=30, face ="bold"),axis.text.y =element_text(size=30, face ="bold"),strip.text.x = element_text(size=30, face ="bold"),strip.text.y = element_text(size=30, face ="bold"), axis.title.y = element_text(size = 30, face ="bold"))+
  scale_colour_manual("Country", values = c("US" = "#78ABC8", "Germany" = "#41698C")
  )+guides(fill=FALSE)

ggsave("F2_main_dread_ols.jpeg", F2_main_dread_ols, height = 14, width = 14*2, dpi = 150)


#Figure - Main Effects on Policy Support Outcomes
mydf_F2_mitigation_US <- data.frame(
  coef = c(coef(summary(F2_main_mitigation_US.ols))[2],coef(summary(F2_main_mitigation_US.ols))[3], coef(summary(F2_main_mitigation_US.ols))[4], coef(summary(F2_main_mitigation_US.ols ))[5]),
  Treatment = factor(c("treatmentGroup_fShort", "treatmentGroup_fLong", "treatmentGroup_fShort-\nContext", "treatmentGroup_fLong-\nContext")),
  se = c(coef(summary(F2_main_mitigation_US.ols ))[2,2], coef(summary(F2_main_mitigation_US.ols))[3,2], coef(summary(F2_main_mitigation_US.ols))[4,2], coef(summary(F2_main_mitigation_US.ols))[5,2]),
  DV = factor(rep(c("General\nMitigation"), 4)),
  country = as.factor("US"))

mydf_F2_mitigation_Germany <- data.frame(
  coef = c(coef(summary(F2_main_mitigation_DE.ols))[2],coef(summary(F2_main_mitigation_DE.ols))[3], coef(summary(F2_main_mitigation_DE.ols))[4], coef(summary(F2_main_mitigation_DE.ols ))[5]),
  Treatment = factor(c("treatmentGroup_fShort", "treatmentGroup_fLong", "treatmentGroup_fShort-\nContext", "treatmentGroup_fLong-\nContext")),
  se = c(coef(summary(F2_main_mitigation_DE.ols ))[2,2], coef(summary(F2_main_mitigation_DE.ols))[3,2], coef(summary(F2_main_mitigation_DE.ols))[4,2], coef(summary(F2_main_mitigation_DE.ols))[5,2]),
  DV = factor(rep(c("General\nMitigation"), 4)),
  country = as.factor("Germany"))


mydf_F2_less_behave_US <- data.frame(
  coef = c(coef(summary(F2_main_less_behave_US.ols))[2],coef(summary(F2_main_less_behave_US.ols))[3], coef(summary(F2_main_less_behave_US.ols))[4], coef(summary(F2_main_less_behave_US.ols ))[5]),
  Treatment = factor(c("treatmentGroup_fShort", "treatmentGroup_fLong", "treatmentGroup_fShort-\nContext", "treatmentGroup_fLong-\nContext")),
  se = c(coef(summary(F2_main_less_behave_US.ols ))[2,2], coef(summary(F2_main_less_behave_US.ols))[3,2], coef(summary(F2_main_less_behave_US.ols))[4,2], coef(summary(F2_main_less_behave_US.ols))[5,2]),
  DV = factor(rep(c("Demand-Side\nMitigation"), 4)),
  country = as.factor("US"))

mydf_F2_less_behave_Germany <- data.frame(
  coef = c(coef(summary(F2_main_less_behave_DE.ols))[2],coef(summary(F2_main_less_behave_DE.ols))[3], coef(summary(F2_main_less_behave_DE.ols))[4], coef(summary(F2_main_less_behave_DE.ols ))[5]),
  Treatment = factor(c("treatmentGroup_fShort", "treatmentGroup_fLong", "treatmentGroup_fShort-\nContext", "treatmentGroup_fLong-\nContext")),
  se = c(coef(summary(F2_main_less_behave_DE.ols ))[2,2], coef(summary(F2_main_less_behave_DE.ols))[3,2], coef(summary(F2_main_less_behave_DE.ols))[4,2], coef(summary(F2_main_less_behave_DE.ols))[5,2]),
  DV = factor(rep(c("Demand-Side\nMitigation"), 4)),
  country = as.factor("Germany"))


b <- rbind(mydf_F2_mitigation_Germany,mydf_F2_mitigation_US,mydf_F2_less_behave_Germany,mydf_F2_less_behave_US)
b$Treatment <- plyr::mapvalues(b$Treatment, c("treatmentGroup_fShort", "treatmentGroup_fLong", "treatmentGroup_fShort-\nContext", "treatmentGroup_fLong-\nContext"), c("Short", "Long", "Short-\nContext", "Long-\nContext"))
b <- b[, names(b) %in% c('Treatment', 'country', 'coef', 'DV', 'se')]
b$Treatment <- mapvalues(b$Treatment, from =c("Short", "Long", "Short-\nContext","Long-\nContext"), to = c("High\nUrgency", "Low\nUrgency", "High\nUrgency + Context","Low\nUrgency + Context"))


F3_main_outcomes_ols <- ggplot(b, aes(x = Treatment, color = country, group =country, y =coef)) + 
  geom_errorbar(aes(ymin=coef - 1.96*se, ymax=coef + 1.96*se), size =3, width=.2, position=pd) +
  #geom_line(position=pd, size =2) +
  geom_point(position=pd, size=3, shape=21, fill="white")+ # 21 is filled circle +
  geom_hline(yintercept = 0, lty="dashed")+
  facet_grid(DV~country, scales ="free")+
  #ylim(c(-0.25,0.75))+
  xlab("") +
  ylab("Average Treatment Effects") +
  ggtitle("Effects of Temporal Framing on Policy Support for General and Demand-Side Mitigation") +
  theme_bw() +
  theme(legend.justification=c(1,0),
        legend.position="")      + 
  theme(plot.title = element_text(size = 34, face = "bold"),legend.title =element_blank(), legend.text = element_text(size = 30, face = "bold"),axis.text.x =element_text(size=30, face ="bold"),axis.text.y =element_text(size=30, face ="bold"),strip.text.x = element_text(size=30, face ="bold"),strip.text.y = element_text(size=30, face ="bold"), axis.title.y = element_text(size = 30, face ="bold"))+
  scale_colour_manual("Country", values = c("US" = "#78ABC8", "Germany" = "#41698C")
  )+guides(fill=FALSE)

ggsave("F3_main_outcomes_ols.jpeg", F3_main_outcomes_ols, height = 14, width = 14*2, dpi = 150)

#Plot OLS Marginal Effects--------
library(margins)
table(df_bind_today$problem_today)


F4_dread_usa <- lm_robust(response_1_dread_n ~ treatmentGroup_f*problem_today , data= subset (df_bind_today, country=="USA" ))
summary(F4_dread_usa)
F4_dread_usa_m <- data.frame(summary(margins (F4_dread_usa, at = list(problem_today = c("No problem today but in future", "Problem today and in future")))))
F4_dread_usa_m$country <- "US"

F4_dread_germany <- lm_robust(response_1_dread_n ~ treatmentGroup_f*problem_today , data= subset (df_bind_today, country=="Germany" ))
summary(F4_dread_germany)
F4_dread_germany_m <- data.frame(summary(margins::margins (F4_dread_germany, at = list(problem_today = c("No problem today but in future", "Problem today and in future")))))
F4_dread_germany_m$country <- "Germany"

b <- rbind(F4_dread_germany_m,F4_dread_usa_m)
b_n <- subset(b, factor !="problem_todayProblem today and in future")
b_n$DV <- "Dread"

b_n$Treatment <- plyr::mapvalues(b_n$factor, c("treatmentGroup_fShort", "treatmentGroup_fLong", "treatmentGroup_fShort-\nContext", "treatmentGroup_fLong-\nContext"), c("Short", "Long", "Short-\nContext", "Long-\nContext"))
b_n$Treatment <- mapvalues(b_n$Treatment, from =c("Short", "Long", "Short-\nContext","Long-\nContext"), to = c("High\nUrgency", "Low\nUrgency", "High\nUrgency + Context","Low\nUrgency + Context"))
b_n$Treatment <- as.factor(b_n$Treatment)
b_n$Treatment <- factor(b_n$Treatment, levels=c("Low\nUrgency", "Low\nUrgency + Context","High\nUrgency","High\nUrgency + Context"))

F4_dread_mm <- ggplot(b_n, aes(x = Treatment, color = problem_today, group =problem_today, y =AME)) + 
  geom_errorbar(aes(ymin=lower, ymax=upper), size =3, width=.2, position=pd) +
  #geom_line(position=pd, size =2) +
  geom_point(position=pd, size=3, shape=21, fill="white")+ # 21 is filled circle +
  geom_hline(yintercept = 0, lty="dashed")+
  facet_grid(.~country, scales ="free")+
  ylim(c(-1,1))+
  xlab("") +
  ylab("Average Marginal Effects") +
  ggtitle("Marginal Effects of Temporal Framing on Feelings of Dread by Temporal Problem Perception") +
  theme_bw() +
  theme(legend.justification=c(1,0),
        legend.position="bottom")      + 
  theme(plot.title = element_text(size = 34, face = "bold"),legend.title =element_blank(), legend.text = element_text(size = 30, face = "bold"),axis.text.x =element_text(size=30, face ="bold"),axis.text.y =element_text(size=30, face ="bold"),strip.text.x = element_text(size=30, face ="bold"),strip.text.y = element_text(size=30, face ="bold"), axis.title.y = element_text(size = 30, face ="bold"))+
  scale_colour_manual("problem_today", values = c("No problem today but in future" = "#78ABC8", "Problem today and in future" = "#41698C"),breaks=c("No problem today but in future", "Problem today and in future"),
                      labels=c("No problem today but in future", "Problem today and in future") )+guides(fill=FALSE)

ggsave("F4_dread_mm.jpeg", F4_dread_mm, height = 14, width = 14*2, dpi = 150)


F5_mitigation_usa <- lm_robust(response_1_mitigation_n ~ treatmentGroup_f*problem_today , data= subset (df_bind_today, country=="USA" ))
F5_mitigation_usa_m <- data.frame(summary(margins (F5_mitigation_usa, at = list(problem_today = c("No problem today but in future", "Problem today and in future")))))
F5_mitigation_usa_m$country <- "US"

F5_mitigation_germany <- lm_robust(response_1_mitigation_n ~ treatmentGroup_f*problem_today , data= subset (df_bind_today, country=="Germany" ))
F5_mitigation_germany_m <- data.frame(summary(margins (F5_mitigation_germany, at = list(problem_today = c("No problem today but in future", "Problem today and in future")))))
F5_mitigation_germany_m$country <- "Germany"


b <- rbind(F5_mitigation_germany_m,F5_mitigation_usa_m)
b_n <- subset(b, factor !="problem_todayProblem today and in future")
b_n$DV <- as.factor("General\nMitigation")


b_n$Treatment <- plyr::mapvalues(b_n$factor, c("treatmentGroup_fShort", "treatmentGroup_fLong", "treatmentGroup_fShort-\nContext", "treatmentGroup_fLong-\nContext"), c("Short", "Long", "Short-\nContext", "Long-\nContext"))

b1 <- b_n


F6_less_behave_usa <- lm_robust(less_behave ~ treatmentGroup_f*problem_today , data= subset (df_bind_today, country=="USA" ))
F6_less_behave_usa_m <- data.frame(summary(margins (F6_less_behave_usa, at = list(problem_today = c("No problem today but in future", "Problem today and in future")))))
F6_less_behave_usa_m$country <- "US"

F6_less_behave_germany <- lm_robust(less_behave ~ treatmentGroup_f*problem_today , data= subset (df_bind_today, country=="Germany" ))
F6_less_behave_germany_m <- data.frame(summary(margins (F6_less_behave_germany, at = list(problem_today = c("No problem today but in future", "Problem today and in future")))))
F6_less_behave_germany_m$country <- "Germany"

b <- rbind(F6_less_behave_germany_m,F6_less_behave_usa_m)
b_n <- subset(b, factor !="problem_todayProblem today and in future")
b_n$DV <- as.factor("Demand-Side\nMitigation")


b_n$Treatment <- plyr::mapvalues(b_n$factor, c("treatmentGroup_fShort", "treatmentGroup_fLong", "treatmentGroup_fShort-\nContext", "treatmentGroup_fLong-\nContext"), c("Short", "Long", "Short-\nContext", "Long-\nContext"))

b2 <- b_n

b3 <- rbind(b1,b2)
b3$Treatment <- mapvalues(b3$Treatment, from =c("Short", "Long", "Short-\nContext","Long-\nContext"), to = c("High\nUrgency", "Low\nUrgency", "High\nUrgency + Context","Low\nUrgency + Context"))
b3$Treatment <- as.factor(b3$Treatment)
b3$Treatment <- factor(b3$Treatment, levels=c("Low\nUrgency", "Low\nUrgency + Context","High\nUrgency","High\nUrgency + Context"))

F5_support_mm <- ggplot(b3, aes(x = Treatment, color = problem_today, group =problem_today, y =AME)) + 
  geom_errorbar(aes(ymin=lower, ymax=upper), size =3, width=.2, position=pd) +
  #geom_line(position=pd, size =2) +
  geom_point(position=pd, size=3, shape=21, fill="white")+ # 21 is filled circle +
  geom_hline(yintercept = 0, lty="dashed")+
  facet_grid(DV~country, scales ="free")+
  ylim(c(-1,1.2))+
  xlab("") +
  ylab("Average Marginal Effects") +
  ggtitle("Marginal Effects of Temporal Framing on Policy Support for Mitigation by Temporal Problem Perception") +
  theme_bw() +
  theme(legend.justification=c(1,0),
        legend.position="bottom")      + 
  theme(plot.title = element_text(size = 34, face = "bold"),legend.title =element_blank(), legend.text = element_text(size = 30, face = "bold"),axis.text.x =element_text(size=30, face ="bold"),axis.text.y =element_text(size=30, face ="bold"),strip.text.x = element_text(size=30, face ="bold"),strip.text.y = element_text(size=30, face ="bold"), axis.title.y = element_text(size = 30, face ="bold"))+
  scale_colour_manual("problem_today", values = c("No problem today but in future" = "#78ABC8", "Problem today and in future" = "#41698C"),breaks=c("No problem today but in future", "Problem today and in future"),
                      labels=c("No problem today but in future", "Problem today and in future") )+guides(fill=FALSE)

ggsave("F5_support_mm.jpeg", F5_support_mm, height = 14, width = 14*2, dpi = 150)


